[gnome-settings-daemon] common: Fix memleak in xdevice_get_last_tool_id()



commit c4e2c60c4a76cbd4f873ed29beecee1c1a1eb7e0
Author: Bastien Nocera <hadess hadess net>
Date:   Fri May 25 13:57:40 2012 +0100

    common: Fix memleak in xdevice_get_last_tool_id()

 plugins/common/gsd-input-helper.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index d4ad9c5..78f1873 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -337,14 +337,16 @@ xdevice_get_last_tool_id (int  deviceid)
         if (!prop)
                 return -1;
 
+        data = NULL;
+
         gdk_error_trap_push ();
 
-        if (!XIGetProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+        if (XIGetProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
                             deviceid, prop, 0, 1000, False,
                             AnyPropertyType, &act_type, &act_format,
-                            &nitems, &bytes_after, &data) == Success) {
+                            &nitems, &bytes_after, &data) != Success) {
                 gdk_error_trap_pop_ignored ();
-                return -1;
+                goto out;
         }
 
         if (gdk_error_trap_pop ())
@@ -375,10 +377,11 @@ xdevice_get_last_tool_id (int  deviceid)
 	/* That means that no tool was set down yet */
 	if (id == STYLUS_DEVICE_ID ||
 	    id == ERASER_DEVICE_ID)
-		return 0x0;
+		id = 0x0;
 
 out:
-        XFree (data);
+        if (data != NULL)
+                XFree (data);
         return id;
 }
 



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