From 4293c36cb91229a2b18308f48d778919e2fe6ddc Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 20 Jan 2021 17:57:08 +0100 Subject: [PATCH] Prevent array-out-of-bounds access. --- src/ArduinoNmeaParser.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ArduinoNmeaParser.cpp b/src/ArduinoNmeaParser.cpp index e25eceb..b9b1cd0 100644 --- a/src/ArduinoNmeaParser.cpp +++ b/src/ArduinoNmeaParser.cpp @@ -106,6 +106,9 @@ void ArduinoNmeaParser::flushParserBuffer() bool ArduinoNmeaParser::isCompleteNmeaMessageInParserBuffer() { + if (_parser_buf_elems < 2) + return false; + char const prev_last = _parser_buf[_parser_buf_elems - 2]; char const last = _parser_buf[_parser_buf_elems - 1];