intel: Fix intelSetTexBuffer miptree leak.
authorKristian Høgsberg <krh@redhat.com>
Fri, 13 Feb 2009 16:05:54 +0000 (11:05 -0500)
committerKristian Høgsberg <krh@redhat.com>
Sat, 21 Feb 2009 19:12:53 +0000 (14:12 -0500)
The intelImage also holds a reference to the miptree, so unref that as well.

src/mesa/drivers/dri/intel/intel_tex_image.c

index c3bbcfc1b9768b488ff80285f3e34409c7ec1be3..943636c37b241daf682f535144c08685ce18cdc6 100644 (file)
@@ -755,16 +755,21 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
 
    _mesa_lock_texture(&intel->ctx, texObj);
 
+   texImage = _mesa_get_tex_image(&intel->ctx, texObj, target, level);
+   intelImage = intel_texture_image(texImage);
+
+   if (intelImage->mt) {
+      intel_miptree_release(intel, &intelImage->mt);
+      assert(!texImage->Data);
+   }
    if (intelObj->mt)
       intel_miptree_release(intel, &intelObj->mt);
 
    intelObj->mt = mt;
-   texImage = _mesa_get_tex_image(&intel->ctx, texObj, target, level);
    _mesa_init_teximage_fields(&intel->ctx, target, texImage,
                              rb->region->width, rb->region->height, 1,
                              0, internalFormat);
 
-   intelImage = intel_texture_image(texImage);
    intelImage->face = target_to_face(target);
    intelImage->level = level;
    texImage->TexFormat = intelChooseTextureFormat(&intel->ctx, internalFormat,