]> git.mdlowis.com Git - proto/labwc.git/commitdiff
ime: fix segfault when IME is killed
authortokyo4j <hrak1529@gmail.com>
Thu, 7 Aug 2025 08:45:30 +0000 (17:45 +0900)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Fri, 8 Aug 2025 11:52:23 +0000 (20:52 +0900)
Fixes up e530f43.

When IME (e.g. fcitx5) is killed, relay->input_method is destroyed and
then relay->input_method->keyboard_grab is destroyed, which causes null
pointer dereference and crashes labwc.

Possible solutions are:
- Let wlroots keep emitting keyboard grab as `data` from keyboard grab's
  destroy handler just like before
- Let wlroots destroy keyboard grab before input method
- Let compositor store keyboard grab as relay->keyboard_grab

But let's just revert the change in e530f43 for now.

src/input/ime.c

index cf8cd2d9b705e096a999f597f18d7f3a9eed14ab..f6e0ac99aee08f85b0691ab0f4fc2a18c14ea087 100644 (file)
@@ -304,8 +304,8 @@ handle_keyboard_grab_destroy(struct wl_listener *listener, void *data)
 {
        struct input_method_relay *relay =
                wl_container_of(listener, relay, keyboard_grab_destroy);
-       struct wlr_input_method_keyboard_grab_v2 *keyboard_grab =
-               relay->input_method->keyboard_grab;
+       struct wlr_input_method_keyboard_grab_v2 *keyboard_grab = data;
+       assert(keyboard_grab);
 
        wl_list_remove(&relay->keyboard_grab_destroy.link);