Permalink
Browse files

backends/x11: Prevent segfault when querying list of devices

The XIQueryDevice function used by device_query_area can return a NULL
pointer and set n_devices to a negative number in some cases. We add
additional checks to prevent a segfault.

https://bugzilla.gnome.org/show_bug.cgi?id=787649
  • Loading branch information...
1 parent 4e7405a commit 8493777961f97b013cced413536938354d7c4f63 @jigpu jigpu committed with jadahl Sep 11, 2017
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/backends/x11/meta-input-settings-x11.c
@@ -589,7 +589,7 @@ device_query_area (ClutterInputDevice *device,
*width = *height = 0;
device_id = clutter_input_device_get_device_id (device);
info = XIQueryDevice (xdisplay, device_id, &n_devices);
- if (n_devices == 0)
+ if (n_devices <= 0 || !info)
return FALSE;
abs_x = XInternAtom (xdisplay, "Abs X", True);

0 comments on commit 8493777

Please sign in to comment.