From 2a71d48a767c86de9d6480585e6e0570eb879699 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 1 Mar 2025 19:24:30 +0100 Subject: [PATCH] inputd: Don't crash when receiving input while there is no active vt --- inputd/src/main.rs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/inputd/src/main.rs b/inputd/src/main.rs index edd0be1a33..93e6b83fdb 100644 --- a/inputd/src/main.rs +++ b/inputd/src/main.rs @@ -420,23 +420,24 @@ impl Scheme for InputScheme { let handle = self.handles.get_mut(&id).ok_or(SysError::new(EINVAL))?; assert!(handle.is_producer()); - let active_vt = self.active_vt.unwrap(); - for handle in self.handles.values_mut() { - match handle { - Handle::Consumer { - pending, - notified, - vt, - .. - } => { - if *vt != active_vt { - continue; - } + if let Some(active_vt) = self.active_vt { + for handle in self.handles.values_mut() { + match handle { + Handle::Consumer { + pending, + notified, + vt, + .. + } => { + if *vt != active_vt { + continue; + } - pending.extend_from_slice(buf); - *notified = false; + pending.extend_from_slice(buf); + *notified = false; + } + _ => continue, } - _ => continue, } }