CheckThousandsGroup: Avoid reading uninitialized data

For the case when word is smaller than 4 characters, we should not look at
the 3rd or 4th character before checking the previous ones, otherwise
we'd at best read uninitialized data, at worse non-existing data.
This commit is contained in:
Samuel Thibault
2022-04-01 20:18:00 +02:00
parent 02dd413a32
commit f352f1e43f
2 changed files with 7 additions and 3 deletions
+4 -3
View File
@@ -1719,13 +1719,14 @@ static bool CheckThousandsGroup(char *word, int group_len)
// Is this a group of 3 digits which looks like a thousands group?
int ix;
if (IsDigit09(word[group_len]) || IsDigit09(-1))
return false;
for (ix = 0; ix < group_len; ix++) {
if (!IsDigit09(word[ix]))
return false;
}
if (IsDigit09(word[group_len]) || IsDigit09(-1))
return false;
return true;
}