From 74a7484ae6bb7045bc7efacc5cb1edc732a27819 Mon Sep 17 00:00:00 2001 From: "Joscha.Wloch" Date: Mon, 13 May 2024 14:32:05 +0200 Subject: [PATCH] clients: keyboard: Prevent NULL context in 'keyboard_handle_key' It can happen that the input context is exited between a key press event and a key release event, as a result it is set to NULL. If the 'keyboard_handle_key' function is called in this case, this leads to a crash. To prevent this, the context is checked beforehand. Signed-off-by: Joscha.Wloch --- clients/keyboard.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clients/keyboard.c b/clients/keyboard.c index 0687eebc9..7a267ca49 100644 --- a/clients/keyboard.c +++ b/clients/keyboard.c @@ -620,6 +620,11 @@ append(char *s1, const char *s2) static void keyboard_handle_key(struct keyboard *keyboard, uint32_t time, const struct key *key, uint32_t key_num, struct input *input, enum wl_pointer_button_state state) { + if (keyboard->keyboard->context == NULL) + { + return; + } + const char *label = NULL; switch(keyboard->state) {