[gtk+/gtk-2-24] Validate the return value of XListInputDevices



commit c5872e2ab9b775071b067a1a23a964a94553741c
Author: Jouke Witteveen <j witteveen gmail com>
Date:   Tue Oct 11 18:16:10 2016 +0200

    Validate the return value of XListInputDevices
    
    Since libxi 1.7.7 XListInputDevices returns NULL when it fails while num_devices will not be set to 0.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772794

 gdk/x11/gdkinput-x11.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/gdk/x11/gdkinput-x11.c b/gdk/x11/gdkinput-x11.c
index 83b5b28..bb908e3 100644
--- a/gdk/x11/gdkinput-x11.c
+++ b/gdk/x11/gdkinput-x11.c
@@ -386,16 +386,18 @@ _gdk_input_common_init (GdkDisplay *display,
                                            event_base, 15 /* Number of events */);
 
       devices = XListInputDevices(display_x11->xdisplay, &num_devices);
-
-      for(loop=0; loop<num_devices; loop++)
+      if (devices)
        {
-         GdkDevicePrivate *gdkdev = gdk_input_device_new(display,
-                                                         &devices[loop],
-                                                         include_core);
-         if (gdkdev)
-           display_x11->input_devices = g_list_append(display_x11->input_devices, gdkdev);
+         for(loop=0; loop<num_devices; loop++)
+           {
+             GdkDevicePrivate *gdkdev = gdk_input_device_new(display,
+                                                             &devices[loop],
+                                                             include_core);
+             if (gdkdev)
+               display_x11->input_devices = g_list_append(display_x11->input_devices, gdkdev);
+           }
+         XFreeDeviceList(devices);
        }
-      XFreeDeviceList(devices);
     }
 
   display_x11->input_devices = g_list_append (display_x11->input_devices, display->core_pointer);


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