[PATCH xserver] xwayland: Do not assume we have a seat

Olivier Fourdan ofourdan at redhat.com
Mon Feb 27 14:19:53 UTC 2017


If a key event is sent programmatically, we may not have an Xwayland
seat associated with it, in which case we end up crashing in
keyboard_check_repeat().

This is the case with "antimicro" which sends key events based on the
joystick buttons.

Avoid the NULL pointer dereference by first checking if the xwl_seat is
non-NULL.

Bugzilla: https://bugzilla.redhat.com/1416244
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
---
 hw/xwayland/xwayland-input.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index cc83ef8..8435da0 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -742,10 +742,16 @@ static Bool
 keyboard_check_repeat (DeviceIntPtr dev, XkbSrvInfoPtr xkbi, unsigned key)
 {
     struct xwl_seat *xwl_seat = dev->public.devicePrivate;
-    struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
+    struct xwl_screen *xwl_screen;
     struct wl_callback *callback;
     struct sync_pending *p;
 
+    /* If we do not have an xwl_seat, it's not coming from the compositor */
+    if (!xwl_seat)
+      return TRUE;
+
+    xwl_screen = xwl_seat->xwl_screen;
+
     /* Make sure we didn't miss a possible reply from the compositor */
     xwl_sync_events (xwl_screen);
 
-- 
2.9.3



More information about the xorg-devel mailing list