From 96c7ed19ce3f9c6a6c5c15dbfe0e2348dca266dc Mon Sep 17 00:00:00 2001 From: mchesser Date: Tue, 7 Nov 2023 16:17:06 +1030 Subject: [PATCH] Handle zero-length SYSEX messages Check that the `storedInputData` buffer is not empty before reading the command ID from the buffer. Fixes: #151 --- src/ConfigurableFirmata.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ConfigurableFirmata.cpp b/src/ConfigurableFirmata.cpp index 03f3bbb..6f46656 100644 --- a/src/ConfigurableFirmata.cpp +++ b/src/ConfigurableFirmata.cpp @@ -213,6 +213,10 @@ int FirmataClass::available(void) */ void FirmataClass::processSysexMessage(void) { + if (sysexBytesRead == 0) { + return; + } + switch (storedInputData[0]) { //first byte in buffer is command case REPORT_FIRMWARE: printFirmwareVersion();