From 74b016202b1989f400f536d3837c8e1259c42c33 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 25 Apr 2025 10:36:59 +0300 Subject: Add missing bounds checks to move-workspace actions Fixes panics. --- src/layout/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/layout/mod.rs') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 317ad0f6..5ade9d01 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -3218,7 +3218,13 @@ impl Layout { if mon_idx == new_idx && ws_idx == workspace_idx { return; } - let ws_id = monitors[new_idx].workspaces[workspace_idx].id(); + + let mon = &monitors[new_idx]; + if mon.workspaces.len() <= workspace_idx { + return; + } + + let ws_id = mon.workspaces[workspace_idx].id(); let mon = &mut monitors[mon_idx]; let activate = activate.map_smart(|| { @@ -3389,6 +3395,10 @@ impl Layout { let current = &mut monitors[current_idx]; + if current.workspaces.len() <= old_idx { + return false; + } + // Do not do anything if the output is already correct if current_idx == target_idx { // Just update the original output since this is an explicit movement action. -- cgit