[at-spi2-core] atspi-misc: Prevent leak



commit c3d2366c74f9ba1f3ba4f4526ddaae34313aefd4
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Jun 24 16:32:31 2012 -0400

    atspi-misc: Prevent leak
    
    We need to free the data that XGetWindowProperty returns back to us.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=678738

 atspi/atspi-misc.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index 6589843..ea132fb 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -1355,7 +1355,8 @@ get_accessibility_bus_address_x11 (void)
   Atom actual_type;
   Display *bridge_display;
   int actual_format;
-  unsigned char *data = NULL;
+  char *data;
+  unsigned char *data_x11 = NULL;
   unsigned long nitems;
   unsigned long leftover;
 
@@ -1372,10 +1373,12 @@ get_accessibility_bus_address_x11 (void)
 		      AT_SPI_BUS, 0L,
 		      (long) BUFSIZ, False,
 		      (Atom) 31, &actual_type, &actual_format,
-		      &nitems, &leftover, &data);
+		      &nitems, &leftover, &data_x11);
   XCloseDisplay (bridge_display);
 
-  return g_strdup (data);
+  data = g_strdup (data_x11);
+  XFree (data_x11);
+  return data;
 }
 
 static char *



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