keyboard: Fix use-after-free in keyboard_finish()

This commit is contained in:
John Lindgren 2022-09-15 19:50:07 -04:00 committed by Consolatis
parent bbc6c6bb94
commit 086a887058

View file

@ -241,8 +241,15 @@ void
keyboard_finish(struct seat *seat)
{
if (seat->keyboard_group) {
/*
* Caution - these event listeners are connected to
* seat->keyboard_group->keyboard and must be
* unregistered before wlr_keyboard_group_destroy(),
* otherwise a use-after-free occurs.
*/
wl_list_remove(&seat->keyboard_key.link);
wl_list_remove(&seat->keyboard_modifiers.link);
wlr_keyboard_group_destroy(seat->keyboard_group);
seat->keyboard_group = NULL;
}
wl_list_remove(&seat->keyboard_key.link);
wl_list_remove(&seat->keyboard_modifiers.link);
}