Skip to content

Commit

Permalink
Fix segfault if key event precedes kbd setup
Browse files Browse the repository at this point in the history
  • Loading branch information
tmccombs committed Mar 26, 2023
1 parent 78aa986 commit 6a21ddc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,11 @@ static void keyboard_handle_modifiers(void *data, struct wl_keyboard *wl_keyboar
const uint32_t mods_latched, const uint32_t mods_locked,
const uint32_t group) {
struct slurp_seat *seat = data;
xkb_state_update_mask(seat->xkb_state, mods_depressed, mods_latched,
mods_locked, 0, 0, group);
// Avoid segfault if this is called before we initialize the keyboard state
if (seat->xkb_state) {
xkb_state_update_mask(seat->xkb_state, mods_depressed, mods_latched,
mods_locked, 0, 0, group);
}
}

static const struct wl_keyboard_listener keyboard_listener = {
Expand Down

0 comments on commit 6a21ddc

Please sign in to comment.