1
1
mirror of https://github.com/swaywm/sway synced 2026-05-04 07:00:38 +02:00
Files
sway/sway
Furkan Sahin d9ae930729 tree/workspace: fix crash on dragging container to workspace edge
When a container is moved, `finalize_move` previously assumed that
calling `workspace_split` would always result in a workspace with exactly
1 child (the wrapper container). Consequently, it safely assumed that
inserting a container with `after = 1` was always valid.

However, if the moved container was the only child of its workspace,
calling `container_detach` drops the workspace's tiling length to 0.
Calling `workspace_split` on an empty workspace simply changes its
layout enum and returns, leaving the length at 0. Passing `after`
(which evaluates to 1 when moving right/down) into
`workspace_insert_tiling` then causes an out-of-bounds insertion and a
subsequent segmentation fault during `container_build_representation`.

This commit fixes the issue by dynamically calculating the insertion
index based on the actual length of the workspace's tiling list at the
moment of insertion, rather than overloading the `after` boolean flag
as a hardcoded index.

(cherry picked from commit c857ca3a97)
2026-04-26 16:34:14 +02:00
..
2024-08-05 02:13:49 +02:00
2025-04-28 23:34:23 +02:00
2025-07-16 10:03:09 +02:00
2026-04-12 18:33:42 +02:00
2025-07-09 01:25:11 +02:00
2026-04-26 16:34:14 +02:00
2021-01-08 09:33:51 +01:00