From 598bbd186b1e6e70a01ba7f98c89404531008f15 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Tue, 7 May 2024 16:50:30 +0100 Subject: [PATCH] window: avoid uaf on updateWindow decos TODO, make these pointers SP to avoid this in the future. fixes #5909 --- src/desktop/Window.cpp | 2 ++ src/desktop/Window.hpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index b4af12f1..00066b27 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -211,6 +211,8 @@ void CWindow::updateWindowDecos() { } for (auto& wd : decos) { + if (std::find_if(m_dWindowDecorations.begin(), m_dWindowDecorations.end(), [wd](const auto& other) { return other.get() == wd; }) == m_dWindowDecorations.end()) + continue; wd->updateWindow(m_pSelf.lock()); } } diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index dd361c30..40e5db49 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -332,6 +332,7 @@ class CWindow { PHLWINDOWREF m_pLastCycledWindow; // Window decorations + // TODO: make this a SP. std::deque> m_dWindowDecorations; std::vector m_vDecosToRemove;