From 4e42107d25dc47ee94da282db233f85f1e4c6bd0 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Thu, 23 May 2024 21:19:14 +0200 Subject: [PATCH] pointermgr: ensure compositor exist on destroy (#6216) on exit of hyprland the CMonitor destroy signal comes after the compositor has been destructed, causing a heap use after free. add if check to ensure compositor exist and isnt shutting down when its triggered. --- src/managers/PointerManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index ae17c6d6..636eab1d 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -131,7 +131,11 @@ CPointerManager::CPointerManager() { PMONITOR->events.modeChanged.registerStaticListener([this](void* owner, std::any data) { onMonitorLayoutChange(); }, nullptr); PMONITOR->events.disconnect.registerStaticListener([this](void* owner, std::any data) { onMonitorLayoutChange(); }, nullptr); PMONITOR->events.destroy.registerStaticListener( - [this](void* owner, std::any data) { std::erase_if(monitorStates, [](const auto& other) { return other->monitor.expired(); }); }, nullptr); + [this](void* owner, std::any data) { + if (g_pCompositor && !g_pCompositor->m_bIsShuttingDown) + std::erase_if(monitorStates, [](const auto& other) { return other->monitor.expired(); }); + }, + nullptr); }); }