From 9d2e7d378ff83a68e6426fff08a8a0573fc9a6ff Mon Sep 17 00:00:00 2001 From: Furkan Sahin Date: Sun, 1 Feb 2026 21:53:06 -0500 Subject: [PATCH] tree/workspace: fix crash on dragging container to workspace edge Problem: when dragging a parent container to the right of its children, sway crashes, the calculated insertion index could exceed the list bounds. The move logic would compute an index based on the pre-removal list state. Solution: Clamp the insertion index to [0, length]. --- sway/tree/workspace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 733a002b4..b57fe5f2c 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -842,6 +842,8 @@ struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace, if (config->default_layout != L_NONE) { con = container_split(con, config->default_layout); } + if (index < 0) index = 0; + else if (index > workspace->tiling->length) index = workspace->tiling->length; workspace_insert_tiling_direct(workspace, con, index); return con; }