xwm: avoid infinite parent lookup loop in lookupParentExists

ref #8045
This commit is contained in:
Vaxry 2024-10-14 00:24:32 +01:00
parent 8e51a36c7f
commit abfd550ee2

View file

@ -150,10 +150,17 @@ void CXWM::handleUnmapNotify(xcb_unmap_notify_event_t* e) {
} }
static bool lookupParentExists(SP<CXWaylandSurface> XSURF, SP<CXWaylandSurface> prospectiveChild) { static bool lookupParentExists(SP<CXWaylandSurface> XSURF, SP<CXWaylandSurface> prospectiveChild) {
std::vector<SP<CXWaylandSurface>> visited;
while (XSURF->parent) { while (XSURF->parent) {
if (XSURF->parent == prospectiveChild) if (XSURF->parent == prospectiveChild)
return true; return true;
visited.emplace_back(XSURF);
XSURF = XSURF->parent.lock(); XSURF = XSURF->parent.lock();
if (std::find(visited.begin(), visited.end(), XSURF) != visited.end())
return false;
} }
return false; return false;