Fix undefined behaviour in xytonode

Sometimes pnode->parent is NULL.
This commit is contained in:
Nikita Ivanov 2023-08-31 18:54:10 +02:00
parent c1d8b77f7f
commit 36bbf8affc

5
dwl.c
View File

@ -2638,8 +2638,11 @@ xytonode(double x, double y, struct wlr_surface **psurface,
surface = wlr_scene_surface_from_buffer( surface = wlr_scene_surface_from_buffer(
wlr_scene_buffer_from_node(node))->surface; wlr_scene_buffer_from_node(node))->surface;
/* Walk the tree to find a node that knows the client */ /* 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; c = pnode->data;
if (!pnode->parent)
break;
}
if (c && c->type == LayerShell) { if (c && c->type == LayerShell) {
c = NULL; c = NULL;
l = pnode->data; l = pnode->data;