Skip to content

Commit 6f5ccbb

Browse files
committed
safety length check
1 parent f466872 commit 6f5ccbb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/SparkFun_LG290P_GNSS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ void LG290P::nmeaHandler(SEMP_PARSE_STATE *parse)
10021002
{
10031003
// Is this a command response?
10041004
std::string sentence = (const char *)parse->buffer;
1005-
if (sentence.substr(sentence.length() - 2) == "\r\n")
1005+
if (sentence.length() >= 2 && sentence.substr(sentence.length() - 2) == "\r\n")
10061006
// if (sentence.ends_with("\r\n"))
10071007
sentence.erase(sentence.size() - 2);
10081008

0 commit comments

Comments
 (0)