From cbb1bf9289cd8c1853306c8f75a7dee3b05939ab Mon Sep 17 00:00:00 2001 From: Ted John Date: Wed, 7 Aug 2019 23:20:50 +0100 Subject: [PATCH] Fix #9752: window_close from ride construction window causes a crash Re-obtain iterator after calling window close event as close event may open / close other windows. --- src/openrct2/interface/Window.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index bac9f59342..302d920dd8 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -230,7 +230,10 @@ void window_close(rct_window* w) // Invalidate the window (area) window_invalidate(window.get()); - g_window_list.erase(itWindow); + // The window list may have been modified in the close event + itWindow = window_get_iterator(w); + if (itWindow != g_window_list.end()) + g_window_list.erase(itWindow); } template static void window_close_by_condition(_TPred pred, uint32_t flags = WindowCloseFlags::None)