Fix use-after-free when the user hovers over an auto-hide plasma panel in wayland...

Edge::handle calls showOnScreenEdge, which (on wayland) eventually calls internalShow, which eventually calls ScreenEdges::reserve, which destroys the same edge.
When showScreenOnEdge returns, 'this' has been freed.
Using a singleshot timer allows Edge::handle to return before the Edge is destroyed.
master
Andreas Haratzis 2020-06-24 22:29:53 -07:00 committed by David Edmundson
parent 2e93829259
commit 71dfd60284
1 changed files with 10 additions and 5 deletions

View File

@ -715,11 +715,16 @@ void XdgToplevelClient::showOnScreenEdge()
if (!m_plasmaShellSurface) {
return;
}
hideClient(false);
workspace()->raiseClient(this);
if (m_plasmaShellSurface->panelBehavior() == PlasmaShellSurfaceInterface::PanelBehavior::AutoHide) {
m_plasmaShellSurface->showAutoHidingPanel();
}
// ShowOnScreenEdge can be called by an Edge, and hideClient could destroy the Edge
// Use the singleshot to avoid use-after-free
QTimer::singleShot(0, [this](){
hideClient(false);
workspace()->raiseClient(this);
if (m_plasmaShellSurface->panelBehavior() == PlasmaShellSurfaceInterface::PanelBehavior::AutoHide) {
m_plasmaShellSurface->showAutoHidingPanel();
}
});
}
void XdgToplevelClient::closeWindow()