[gnome-settings-daemon] mouse: be more careful to avoid segfaults



commit ababd23637d9da91bc30bd9ce6ec144e91313ac6
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Aug 27 13:28:42 2011 -0400

    mouse: be more careful to avoid segfaults
    
    It appears that X can sometimes give us NULL for a device,
    but then can't handle given NULL back as a device :-(
    
    https://bugzilla.gnome.org/show_bug.cgi?id=657462

 plugins/mouse/gsd-mouse-manager.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/plugins/mouse/gsd-mouse-manager.c b/plugins/mouse/gsd-mouse-manager.c
index fbf6374..843a57e 100644
--- a/plugins/mouse/gsd-mouse-manager.c
+++ b/plugins/mouse/gsd-mouse-manager.c
@@ -406,14 +406,14 @@ set_motion (GsdMouseManager *manager,
         guint i;
 
         xdevice = open_gdk_device (device);
+        if (xdevice == NULL)
+                return;
+
         if (device_is_touchpad (xdevice))
                 settings = manager->priv->touchpad_settings;
         else
                 settings = manager->priv->mouse_settings;
 
-        if (xdevice == NULL)
-                return;
-
         /* Calculate acceleration */
         motion_acceleration = g_settings_get_double (settings, KEY_MOTION_ACCELERATION);
 
@@ -576,6 +576,8 @@ set_tap_to_click (GdkDevice *device,
                 return;
 
         xdevice = open_gdk_device (device);
+        if (xdevice == NULL)
+                return;
 
         if (!device_is_touchpad (xdevice)) {
                 XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
@@ -623,6 +625,8 @@ set_horiz_scroll (GdkDevice *device,
                 return;
 
         xdevice = open_gdk_device (device);
+        if (xdevice == NULL)
+                return;
 
         if (!device_is_touchpad (xdevice)) {
                 XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
@@ -684,6 +688,8 @@ set_edge_scroll (GdkDevice               *device,
                 return;
 
         xdevice = open_gdk_device (device);
+        if (xdevice == NULL)
+                return;
 
         if (!device_is_touchpad (xdevice)) {
                 XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);



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