From 5f96194e9e8c34c2f24098d5e456ee1804690d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 3 Aug 2022 23:01:00 +0200 Subject: [PATCH] window/wayland: Always update the monitor when updating If the window didn't have a size, it would still have a monitor, and when we are asked to update, we must update, as the old monitor might not be kept around, leaving us vulnerable to use after free. Avoid not updating the monitor by using the stored IDs (preferred, or previous) to find suitable logical monitors, with the primary monitor being the last fallback unless we're completely headless. This fixes the assert !window->monitor || g_list_find (meta_monitor_manager_get_logical_monitors (monitor_manager), window->monitor) in meta_window_update_for_monitors_changed() being hit when a Wayland window has been created, but not mapped, when a hotplug happens. Part-of: --- src/wayland/meta-window-wayland.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index 53a007803..d8ece0bd7 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -490,7 +490,10 @@ meta_window_wayland_update_main_monitor (MetaWindow *window, } if (window->rect.width == 0 || window->rect.height == 0) - return; + { + window->monitor = meta_window_find_monitor_from_id (window); + return; + } /* Require both the current and the new monitor would be the new main monitor, * even given the resulting scale the window would end up having. This is