From 50e090071cba2231c3c5201d45fdeeae8659fb64 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 25 Dec 2021 10:39:47 +0100 Subject: [PATCH] WindowServer: Skip over destroyed windows in WindowSwitcher::draw() I encountered a WindowServer crash due to null-pointer dereference in this function, so let's protect against it by simply skipping over nulled-out WeakPtrs. I added a FIXME about how we ideally wouldn't be in this situation in the first place, but that will require some more investigation. --- Userland/Services/WindowServer/WindowSwitcher.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Services/WindowServer/WindowSwitcher.cpp b/Userland/Services/WindowServer/WindowSwitcher.cpp index bb7321e4f1..f5b41727be 100644 --- a/Userland/Services/WindowServer/WindowSwitcher.cpp +++ b/Userland/Services/WindowServer/WindowSwitcher.cpp @@ -183,6 +183,9 @@ void WindowSwitcher::draw() } for (size_t index = 0; index < m_windows.size(); ++index) { + // FIXME: Ideally we wouldn't be in draw() without having pruned destroyed windows from the list already. + if (m_windows.at(index) == nullptr) + continue; auto& window = *m_windows.at(index); auto item_rect = this->item_rect(index); Color text_color;