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 <Joscha.Wloch@bruker.com>
This commit is contained in:
Joscha.Wloch 2024-05-13 14:32:05 +02:00 committed by Joscha Wloch
parent 366d11c3ee
commit 74a7484ae6

View file

@ -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) {