From 36bbf8affc62b0dc752fd8ac5b7b5cb4035c226b Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Thu, 31 Aug 2023 18:54:10 +0200 Subject: [PATCH] Fix undefined behaviour in xytonode Sometimes pnode->parent is NULL. --- dwl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index 4ff5c37..c9ec812 100644 --- a/dwl.c +++ b/dwl.c @@ -2638,8 +2638,11 @@ xytonode(double x, double y, struct wlr_surface **psurface, surface = wlr_scene_surface_from_buffer( wlr_scene_buffer_from_node(node))->surface; /* Walk the tree to find a node that knows the client */ - for (pnode = node; pnode && !c; pnode = &pnode->parent->node) + for (pnode = node; pnode && !c; pnode = &pnode->parent->node) { c = pnode->data; + if (!pnode->parent) + break; + } if (c && c->type == LayerShell) { c = NULL; l = pnode->data;