diff --git a/types/wlr_scene.c b/types/wlr_scene.c index 99b8076a..f35870bc 100644 --- a/types/wlr_scene.c +++ b/types/wlr_scene.c @@ -138,6 +138,13 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node, if (node->parent == new_parent) { return; } + /* Ensure that a node cannot become its own ancestor */ + for (struct wlr_scene_node *ancestor = new_parent; ancestor != NULL; + ancestor = ancestor->parent) { + if (ancestor == node) { + return; + } + } wl_list_remove(&node->state.link);