is_decimal: Fix an integer underflow.

It seems harmless though.

Found by UBSAN

parson.c:270:18: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'size_t' (aka 'unsigned long')
This commit is contained in:
YAMAMOTO Takashi 2020-09-18 09:25:21 +09:00
parent 102a4467e1
commit 2b7adfe306

View File

@ -274,7 +274,8 @@ static int is_decimal(const char *string, size_t length) {
if (length > 2 && !strncmp(string, "-0", 2) && string[2] != '.') {
return 0;
}
while (length--) {
while (length) {
length--;
if (strchr("xX", string[length])) {
return 0;
}