From be1e58beecaf9e831a932a9873ecdad90618e71d Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Wed, 1 Apr 2026 20:04:31 -0500 Subject: [PATCH] clients: Fix crash when removing and reinserting outputs If we don't receive a surface_leave before an output_destroy, the window output lists can hold a stale reference to the destroyed output. Call surface_leave for the output on all windows to make sure it's not on any lists. Signed-off-by: Derek Foreman --- clients/window.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/clients/window.c b/clients/window.c index acc6667f6..90440c114 100644 --- a/clients/window.c +++ b/clients/window.c @@ -5946,6 +5946,19 @@ display_destroy_output(struct display *d, uint32_t id) wl_list_for_each(output, &d->output_list, link) { if (output->server_output_id == id) { + struct window *window; + + /* If a window was on a destroyed output, we need to + * make sure the output doesn't linger on the window's + * output list. + * surface_leave does nothing if the output isn't on + * the list, so we can call it for all windows to remove + * this output. + */ + wl_list_for_each(window, &d->window_list, link) { + surface_leave(window, NULL, output->output); + } + output_destroy(output); break; }