From 3e7d3b8eec40e8b39360845b50e02a52829a2abe Mon Sep 17 00:00:00 2001 From: Furkan Sahin Date: Sun, 1 Feb 2026 21:53:06 -0500 Subject: 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 733a002b..ddae8de4 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -842,6 +842,11 @@ 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; } -- cgit v1.2.3