From 538a7a190dacd4068908e44bbd0a8a5143aaba69 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Fri, 22 Mar 2024 21:34:48 +0000 Subject: [PATCH] types/text-input-v3: assert on invalid _leave() and _enter() calls It's invalid usage, but shouldn't cause memory mayhem, assert instead --- types/wlr_text_input_v3.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/wlr_text_input_v3.c b/types/wlr_text_input_v3.c index 936eca1a..0b05ca65 100644 --- a/types/wlr_text_input_v3.c +++ b/types/wlr_text_input_v3.c @@ -25,6 +25,7 @@ void wlr_text_input_v3_send_enter(struct wlr_text_input_v3 *text_input, struct wlr_surface *surface) { assert(wl_resource_get_client(text_input->resource) == wl_resource_get_client(surface->resource)); + assert(text_input->focused_surface == NULL); text_input->focused_surface = surface; wl_signal_add(&text_input->focused_surface->events.destroy, &text_input->surface_destroy); @@ -33,6 +34,7 @@ void wlr_text_input_v3_send_enter(struct wlr_text_input_v3 *text_input, } void wlr_text_input_v3_send_leave(struct wlr_text_input_v3 *text_input) { + assert(text_input->focused_surface != NULL); zwp_text_input_v3_send_leave(text_input->resource, text_input->focused_surface->resource); text_input_clear_focused_surface(text_input);