[gnome-settings-daemon/gnome-3-0] mouse: Don't crash if mouse has no FeedbackStates



commit 52c8c0079542c091fa02b9b0b871d6c22fa68cc4
Author: Bastien Nocera <hadess hadess net>
Date:   Fri May 6 18:38:55 2011 +0100

    mouse: Don't crash if mouse has no FeedbackStates
    
    When XGetFeedbackControl fails, it returns NULL, and num_feedbacks
    might not have been set to a decent value. We should check the return
    value instead of thinking that num_feedbacks will always have a
    valid value.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649539

 plugins/mouse/gsd-mouse-manager.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/plugins/mouse/gsd-mouse-manager.c b/plugins/mouse/gsd-mouse-manager.c
index cccc00f..80f664a 100644
--- a/plugins/mouse/gsd-mouse-manager.c
+++ b/plugins/mouse/gsd-mouse-manager.c
@@ -447,6 +447,8 @@ set_motion (GsdMouseManager *manager,
 
         /* Get the list of feedbacks for the device */
         states = XGetFeedbackControl (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice, &num_feedbacks);
+        if (states == NULL)
+                num_feedbacks = 0;
         state = (XFeedbackState *) states;
         for (i = 0; i < num_feedbacks; i++) {
                 if (state->class == PtrFeedbackClass) {



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