From 50edc17fc4981ccd3d56979569a5072a103cf577 Mon Sep 17 00:00:00 2001 From: Daniel Gallups Date: Thu, 5 Dec 2024 22:11:55 -0500 Subject: [PATCH] fix: panic on connect to input Upon inspection, it appears the received message will continuously send a single byte `11110000` when no keys are pressed. The length of this value is 1 byte. Not sure what this means or how MIDI works, but checking that the input length is equal to 3 fixes this problem. --- src/input.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/input.rs b/src/input.rs index e973de6..8a2535c 100644 --- a/src/input.rs +++ b/src/input.rs @@ -241,6 +241,9 @@ impl Future for MidiInputTask { &port, self.settings.port_name, move |stamp, message, _| { + if message.len() != 3 { + return; + } let _ = s.send(Reply::Midi(MidiData { stamp, message: [message[0], message[1], message[2]].into(),