window: Fix logic for looking up widget default cursor
authorKristian Høgsberg <krh@bitplanet.net>
Thu, 15 Aug 2013 21:15:18 +0000 (14:15 -0700)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 16 Aug 2013 17:55:59 +0000 (10:55 -0700)
We may deref a NULL pointer if there is no grab and no focus widget.

clients/window.c

index d701889..e9b6a5e 100644 (file)
@@ -2911,12 +2911,15 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer,
                widget = input->grab;
        else
                widget = input->focus_widget;
-       if (widget && widget->motion_handler)
-               cursor = widget->motion_handler(input->focus_widget,
-                                               input, time, sx, sy,
-                                               widget->user_data);
-       else
-               cursor = input->focus_widget->default_cursor;
+       if (widget) {
+               if (widget->motion_handler)
+                       cursor = widget->motion_handler(input->focus_widget,
+                                                       input, time, sx, sy,
+                                                       widget->user_data);
+               else
+                       cursor = widget->default_cursor;
+       } else
+               cursor = CURSOR_LEFT_PTR;
 
        input_set_pointer_image(input, cursor);
 }