From 152487e494993ad7fb5633a27c7d7ad0f8810ea5 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 25 Oct 2026 12:08:15 +0100 Subject: wayland: update_terms_on_monitor(): skip terminals in the process of shutting down In rare cases, xdg_output_handle_done() may be called while a terminal is shutting down. This triggered a crash in update_terms_for_monitor(), which de-references term->window (which is NULL for terminals shutting down). Closes #2487 --- CHANGELOG.md | 3 +++ wayland.c | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcfa0262..d1a25691 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,11 +93,14 @@ * Possible memory leak when processing keymap data ([#2482][2482]). * Word-wise selection sometimes not working properly due to incorrect selection direction ([#2483][2483]). +* Crash in `xdg_output_handle_done()` if called when a terminal is in + the process of shutting down ([#2487][2487]). [2432]: https://codeberg.org/dnkl/foot/pulls/2432 [2467]: https://codeberg.org/dnkl/foot/issues/2467 [2482]: https://codeberg.org/dnkl/foot/pulls/2482 [2483]: https://codeberg.org/dnkl/foot/issues/2483 +[2487]: https://codeberg.org/dnkl/foot/issues/2487 ### Security diff --git a/wayland.c b/wayland.c index f15c1687..a47764e4 100644 --- a/wayland.c +++ b/wayland.c @@ -439,14 +439,15 @@ update_term_for_output_change(struct terminal *term) return; } else if (term->conf->dpi_aware) { /* - * If fonts are sized according to DPI, it is possible for the cell - * size to remain the same when display scale changes. This will not - * change the surface buffer dimensions, but will change the logical - * size of the window. To ensure that the compositor is made aware of - * the proper logical size, force a resize rather than allowing - * render_resize() to shortcut the notification if the buffer - * dimensions remain the same. - */ + * If fonts are sized according to DPI, it is possible for the + * cell size to remain the same when display scale + * changes. This will not change the surface buffer + * dimensions, but will change the logical size of the + * window. To ensure that the compositor is made aware o the + * proper logical size, force a resize rather than allowing + * render_resize() to shortcut the notification if the buffer + * dimensions remain the same. + */ resize_opts |= RESIZE_FORCE; } @@ -464,6 +465,8 @@ update_terms_on_monitor(struct monitor *mon) tll_foreach(wayl->terms, it) { struct terminal *term = it->item; + if (unlikely(term->shutdown.in_progress)) + continue; tll_foreach(term->window->on_outputs, it2) { if (it2->item == mon) { -- cgit v1.3