Fix offset used before range check

Accessing an array offset before checking the range means that the
program may attempt to read beyond the end of a buffer.
This commit is contained in:
Mingjie Shen 2023-05-24 18:30:01 -04:00 committed by rusefillc
parent 5287fad220
commit b37e61b8ae
1 changed files with 1 additions and 1 deletions

View File

@ -64,7 +64,7 @@ static int str_till_comma(const char * const a, char * const dStr) {
if (sLen > GPS_MAX_STRING)
sLen = GPS_MAX_STRING;
while (a[i] != 44 && i < sLen) { // while not comma or end
while (i < sLen && a[i] != 44) { // while not comma or end
dStr[i] = a[i];
i++;
}