[PATCH 2/5] glamor: Fix memory leak in _glamor_copy_n_to_n()

Michel Dänzer michel at daenzer.net
Wed Apr 23 02:54:42 PDT 2014


From: Michel Dänzer <michel.daenzer at amd.com>

It would leak the memory allocated for the region rects in some cases.
Found with valgrind.

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
Reviewed-by: Zhigang Gong <zhigang.gong at linux.intel.com>
Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 glamor/glamor_copyarea.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c
index 6e90e36..e198822 100644
--- a/glamor/glamor_copyarea.c
+++ b/glamor/glamor_copyarea.c
@@ -367,7 +367,7 @@ _glamor_copy_n_to_n(DrawablePtr src,
             goto fall_back;
         glamor_make_current(glamor_priv);
         if (!glamor_set_alu(screen, gc->alu)) {
-            goto fail;
+            goto fail_noregion;
         }
     }
 
@@ -533,7 +533,6 @@ _glamor_copy_n_to_n(DrawablePtr src,
         if (n_dst_region == 0)
             ok = TRUE;
         free(clipped_dst_regions);
-        RegionUninit(&region);
     }
     else {
         ok = __glamor_copy_n_to_n(src, dst, gc, box, nbox, dx, dy,
@@ -541,6 +540,8 @@ _glamor_copy_n_to_n(DrawablePtr src,
     }
 
  fail:
+    RegionUninit(&region);
+ fail_noregion:
     glamor_make_current(glamor_priv);
     glamor_set_alu(screen, GXcopy);
 
-- 
1.9.2



More information about the xorg-devel mailing list