diff --git a/CHANGELOG.md b/CHANGELOG.md index dec74bc1..f2d84b72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,9 +80,12 @@ * Workaround for buggy compositors (e.g. some versions of GNOME) allowing drag-and-drops even though foot has reported it does not support the offered mime-types ([#1092][1092]). +* Crash when compositor sends a _”keyboard key”_ event without a prior + _”keyboard enter”_ event ([#1097][1097]). [1055]: https://codeberg.org/dnkl/foot/issues/1055 [1092]: https://codeberg.org/dnkl/foot/issues/1092 +[1097]: https://codeberg.org/dnkl/foot/issues/1092 ### Security diff --git a/input.c b/input.c index fca46050..cd2608fd 100644 --- a/input.c +++ b/input.c @@ -1572,6 +1572,18 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { struct seat *seat = data; + + if (unlikely(seat->kbd_focus == NULL)) { + LOG_WARN( + "compositor sent 'keyboard key %s' event on seat %s " + "without a prior 'keyboard enter' event", + (state == WL_KEYBOARD_KEY_STATE_PRESSED + ? "pressed" + : "released"), + seat->name); + return; + } + key_press_release(seat, seat->kbd_focus, serial, key + 8, state); }