From 8493777961f97b013cced413536938354d7c4f63 Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Mon, 11 Sep 2017 11:51:44 -0700 Subject: [PATCH] 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 --- src/backends/x11/meta-input-settings-x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/x11/meta-input-settings-x11.c b/src/backends/x11/meta-input-settings-x11.c index c833296a6..98d05a9ed 100644 --- a/src/backends/x11/meta-input-settings-x11.c +++ b/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);