From 3fcb7f0aaf48f2b96a77818693a4032e3ed604c4 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Wed, 30 Mar 2022 23:24:55 +0200 Subject: [PATCH] input: Don't allow more than MAX_WORKSPACES --- src/shell/mod.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 02381b19..0cdaf16e 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -191,6 +191,10 @@ impl Shell { } pub fn activate(&mut self, seat: &Seat, output: &Output, idx: usize) { + if idx > MAX_WORKSPACES { + return; + } + match self.mode { Mode::OutputBound => { for output in &self.outputs { @@ -237,16 +241,20 @@ impl Shell { }; } - pub fn move_current_window(&mut self, seat: &Seat, output: &Output, idx: u8) { + pub fn move_current_window(&mut self, seat: &Seat, output: &Output, idx: usize) { + if idx > MAX_WORKSPACES { + return; + } + let workspace = self.active_space_mut(output); - if idx == workspace.idx { + if idx == workspace.idx as usize { return; } let maybe_window = workspace.focus_stack(seat).last(); if let Some(window) = maybe_window { workspace.unmap_window(&window); - self.spaces[idx as usize].map_window(&window, seat); + self.spaces[idx].map_window(&window, seat); } }