[metacity] compositor: fix memory leak



commit 48af4930350434d7978dc099fd4354224371f062
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Jul 14 15:15:37 2016 +0300

    compositor: fix memory leak

 src/compositor/compositor-xrender.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/compositor/compositor-xrender.c b/src/compositor/compositor-xrender.c
index 78c3f5b..b9923e6 100644
--- a/src/compositor/compositor-xrender.c
+++ b/src/compositor/compositor-xrender.c
@@ -860,7 +860,8 @@ root_tile (MetaScreen *screen)
   Display *xdisplay = meta_display_get_xdisplay (display);
   Picture picture;
   Pixmap pixmap;
-  gboolean fill = FALSE;
+  gboolean free_pixmap;
+  gboolean fill;
   XRenderPictureAttributes pa;
   XRenderPictFormat *format;
   int p;
@@ -870,6 +871,9 @@ root_tile (MetaScreen *screen)
   Window xroot = meta_screen_get_xroot (screen);
 
   pixmap = None;
+  free_pixmap = FALSE;
+  fill = FALSE;
+
   background_atoms[0] = DISPLAY_COMPOSITOR (display)->atom_x_root_pixmap;
   background_atoms[1] = DISPLAY_COMPOSITOR (display)->atom_x_set_root;
 
@@ -893,7 +897,6 @@ root_tile (MetaScreen *screen)
             {
               memcpy (&pixmap, prop, 4);
               XFree (prop);
-              fill = FALSE;
               break;
             }
         }
@@ -925,6 +928,8 @@ root_tile (MetaScreen *screen)
           XSync (xdisplay, False);
 
           XFreeGC (xdisplay, gc);
+
+          free_pixmap = TRUE;
         }
     }
 
@@ -933,6 +938,8 @@ root_tile (MetaScreen *screen)
       pixmap = XCreatePixmap (xdisplay, xroot, 1, 1,
                               DefaultDepth (xdisplay, screen_number));
       g_return_val_if_fail (pixmap != None, None);
+
+      free_pixmap = TRUE;
       fill = TRUE;
     }
 
@@ -953,9 +960,11 @@ root_tile (MetaScreen *screen)
       c.alpha = 0xffff;
 
       XRenderFillRectangle (xdisplay, PictOpSrc, picture, &c, 0, 0, 1, 1);
-      XFreePixmap (xdisplay, pixmap);
     }
 
+  if (free_pixmap)
+    XFreePixmap (xdisplay, pixmap);
+
   return picture;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]