summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPekka Paalanen <ppaalanen@gmail.com>2011-11-28 16:13:57 +0200
committerKristian Høgsberg <krh@bitplanet.net>2011-12-02 06:31:08 -0500
commita03a93c6ea0564087e4bd66108e0e01cb2522bdc (patch)
treeb0e3e6a17e27467c8457e9ceb16d0fda8f853951
parentfe340830231294e289ca19867ea1f3bbf5ca1293 (diff)
window: fix segfault in window_handle_key()
When a window destroyed, if any input had the window in keyboard focus, the keyboard focus is reset to NULL. A new keyboard focus is set only, if the user clicks something. If the user presses a key instead of clicking, the key press event is sent to the client which has NULL keyboard focus, triggering a segfault in window_handle_key(). Fix the segfault by ignoring the key event, if there is no target window. I triggered this segfault by clicking the unlock dialog away, and then pressing a key. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
-rw-r--r--clients/window.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/clients/window.c b/clients/window.c
index 1c8b9ad..5324795 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1314,11 +1314,11 @@ window_handle_key(void *data, struct wl_input_device *input_device,
{
struct input *input = data;
struct window *window = input->keyboard_focus;
- struct display *d = window->display;
+ struct display *d = input->display;
uint32_t code, sym, level;
code = key + d->xkb->min_key_code;
- if (window->keyboard_device != input)
+ if (!window || window->keyboard_device != input)
return;
level = 0;
@@ -1394,7 +1394,6 @@ window_handle_keyboard_focus(void *data,
struct display *d = input->display;
uint32_t *k, *end;
- window = input->keyboard_focus;
if (window) {
window->keyboard_device = NULL;
if (window->keyboard_focus_handler)