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.
This commit is contained in:
Andreas Haratzis 2020-06-24 22:29:53 -07:00 committed by David Edmundson
parent 2e93829259
commit 71dfd60284

View file

@ -715,11 +715,16 @@ void XdgToplevelClient::showOnScreenEdge()
if (!m_plasmaShellSurface) {
return;
}
// 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()