mirror of
https://github.com/swaywm/sway.git
synced 2026-04-27 06:46:25 -04:00
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)
This commit is contained in:
parent
655b9a7e55
commit
d9ae930729
1 changed files with 1 additions and 1 deletions
|
|
@ -373,7 +373,7 @@ static void finalize_move(struct sway_seat *seat) {
|
||||||
enum sway_container_layout new_layout = edge == WLR_EDGE_TOP ||
|
enum sway_container_layout new_layout = edge == WLR_EDGE_TOP ||
|
||||||
edge == WLR_EDGE_BOTTOM ? L_VERT : L_HORIZ;
|
edge == WLR_EDGE_BOTTOM ? L_VERT : L_HORIZ;
|
||||||
workspace_split(new_ws, new_layout);
|
workspace_split(new_ws, new_layout);
|
||||||
workspace_insert_tiling(new_ws, con, after);
|
workspace_insert_tiling(new_ws, con, after ? new_ws->tiling->length : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old_parent) {
|
if (old_parent) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue