popups: fix heap-use-after-free

This commit is contained in:
vaxerski 2023-03-23 00:22:28 +00:00
parent cf51a31807
commit 3a3a3f7bdb

View file

@ -173,11 +173,6 @@ void Events::listener_unmapPopupXDG(void* owner, void* data) {
ASSERT(PPOPUP); ASSERT(PPOPUP);
if (PPOPUP->parentWindow)
std::erase(PPOPUP->parentWindow->m_lPopupSurfaces, PPOPUP->popup->base->surface);
else if (PPOPUP->parentLS)
std::erase(PPOPUP->parentLS->popupSurfaces, PPOPUP->popup->base->surface);
SubsurfaceTree::destroySurfaceTree(PPOPUP->pSurfaceTree); SubsurfaceTree::destroySurfaceTree(PPOPUP->pSurfaceTree);
int lx = 0, ly = 0; int lx = 0, ly = 0;
@ -188,6 +183,11 @@ void Events::listener_unmapPopupXDG(void* owner, void* data) {
g_pHyprRenderer->damageBox(lx - extents.x, ly - extents.y, extents.width + 2, extents.height + 2); g_pHyprRenderer->damageBox(lx - extents.x, ly - extents.y, extents.width + 2, extents.height + 2);
if (PPOPUP->parentWindow)
std::erase(PPOPUP->parentWindow->m_lPopupSurfaces, PPOPUP->popup->base->surface);
else if (PPOPUP->parentLS)
std::erase(PPOPUP->parentLS->popupSurfaces, PPOPUP->popup->base->surface);
PPOPUP->pSurfaceTree = nullptr; PPOPUP->pSurfaceTree = nullptr;
g_pInputManager->simulateMouseMovement(); // to focus and return back to an appropriate surface g_pInputManager->simulateMouseMovement(); // to focus and return back to an appropriate surface