From f1b40bc288f3be3bcc6a3c71f28ca9bb2529e70b Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Fri, 22 May 2026 23:03:31 +0800 Subject: [PATCH] seatop_move_tiling: fix stack overflow when dropping container into itself This change avoids a cyclic reference in the window tree when dragging a container and dropping it into one of its descendants. The drop target resolution logic previously only checked if the target node was the container itself, but missed checking if the target was a descendant of the dragged container. Fixes: #7949 --- sway/input/seatop_move_tiling.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sway/input/seatop_move_tiling.c b/sway/input/seatop_move_tiling.c index 3a764d9ac..025197852 100644 --- a/sway/input/seatop_move_tiling.c +++ b/sway/input/seatop_move_tiling.c @@ -256,8 +256,9 @@ static void handle_motion_postthreshold(struct sway_seat *seat) { } if (edge) { e->target_node = node_get_parent(&con->node); - if (e->target_node == &e->con->node) { - e->target_node = node_get_parent(e->target_node); + if (e->target_node && (e->target_node == &e->con->node || + node_has_ancestor(e->target_node, &e->con->node))) { + e->target_node = node_get_parent(&e->con->node); } e->target_edge = edge; update_indicator(e, &box);