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
This commit is contained in:
Jason Gerecke 2017-09-11 11:51:44 -07:00 committed by Jonas Ådahl
parent 4e7405aca9
commit 8493777961

View File

@ -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);