intel: Don't leak the tex object miptree when replacing it
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 28 Mar 2011 17:13:25 +0000 (10:13 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 29 Mar 2011 02:54:51 +0000 (19:54 -0700)
Eventually the miptree refcounting interface should be cleaned up.
The assymmetry dramatically increases the probability of bugs like
this.  It should be made to like like libdrm refcounting or the
refcounting style used in other parts of Mesa.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=33046

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/intel/intel_tex_image.c

index 906f8a62710b5bf28e34a33039e1cd3c2109854f..b3a2b1b0c85057487575e261ecdf43e2b5c71289 100644 (file)
@@ -370,8 +370,10 @@ intelTexImage(struct gl_context * ctx,
        * whole object since our level didn't fit what was there
        * before, and any lower levels would fit into our miptree.
        */
-      if (intelImage->mt)
+      if (intelImage->mt) {
+        intel_miptree_release(intel, &intelObj->mt);
         intel_miptree_reference(&intelObj->mt, intelImage->mt);
+      }
    }
 
    /* PBO fastpaths: