From 0f534e32e4f1d021a1faca6ecbb694c7f4808761 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 28 Aug 2021 18:10:09 -0500 Subject: scene: ensure node cannot be reparented below itself --- types/wlr_scene.c | 7 +++++++ 1 file changed, 7 insertions(+) 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); -- cgit v1.2.3