diff options
author | Devin J. Pohly <djpohly@gmail.com> | 2021-08-28 18:10:09 -0500 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-08-30 16:43:18 +0200 |
commit | 0f534e32e4f1d021a1faca6ecbb694c7f4808761 (patch) | |
tree | 6ee0981c20e081f7ba08ae6afb69da580cbc6ef2 | |
parent | a1d462fa81682d4820d13020769ba86286868b60 (diff) |
scene: ensure node cannot be reparented below itself
-rw-r--r-- | types/wlr_scene.c | 7 |
1 files changed, 7 insertions, 0 deletions
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); |