[Mesa-dev] [PATCH] intel: Fix memory leak in intel_miptree_create()

Chad Versace chad.versace at linux.intel.com
Tue Dec 27 10:16:05 PST 2011


On failure, intel_miptree_create() needs to *release* the miptree, not
just free it, so that the stencil_mt gets released too.

CC: Eric Anholt <eric at anholt.net>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index e0f9632..00a81ca 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -204,7 +204,7 @@ intel_miptree_create(struct intel_context *intel,
     * pitch == 0 || height == 0  indicates the null texture
     */
    if (!mt || !mt->total_width || !mt->total_height) {
-      free(mt);
+      intel_miptree_release(&mt);
       return NULL;
    }
 
@@ -216,7 +216,7 @@ intel_miptree_create(struct intel_context *intel,
 				   expect_accelerated_upload);
 
    if (!mt->region) {
-       free(mt);
+       intel_miptree_release(&mt);
        return NULL;
    }
 
-- 
1.7.7.4



More information about the mesa-dev mailing list