From d858351a614bc807e664d670ad5359743bb8f5df Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 3 Aug 2012 14:39:11 +0300 Subject: [PATCH] compositor-drm, evdev: don't crash on missing keyboard Weston's notify_keyboard_focus_*() assume that a keyboard is present, if they are called. With evdev, there might not always be a keyboard. Also clean up the variable definition in evdev_notify_keyborad_focus(). I read that function through many times and finally had to grep where does 'all_keys' come from. Signed-off-by: Pekka Paalanen --- src/compositor-drm.c | 3 ++- src/evdev.c | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index eab5f5c2..bcd8aacb 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -2012,7 +2012,8 @@ evdev_remove_devices(struct weston_seat *seat_base) wl_list_for_each_safe(device, next, &seat->devices_list, link) evdev_input_device_destroy(device); - notify_keyboard_focus_out(&seat->base.seat); + if (seat->base.seat.keyboard) + notify_keyboard_focus_out(&seat->base.seat); } static void diff --git a/src/evdev.c b/src/evdev.c index 7efbc7da..09275f44 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -561,10 +561,14 @@ evdev_notify_keyboard_focus(struct weston_seat *seat, struct evdev_input_device *device; struct wl_array keys; unsigned int i, set; - char evdev_keys[(KEY_CNT + 7) / 8], all_keys[(KEY_CNT + 7) / 8]; + char evdev_keys[(KEY_CNT + 7) / 8]; + char all_keys[(KEY_CNT + 7) / 8]; uint32_t *k; int ret; + if (!seat->seat.keyboard) + return; + memset(all_keys, 0, sizeof all_keys); wl_list_for_each(device, evdev_devices, link) { memset(evdev_keys, 0, sizeof evdev_keys);