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')
pull/145/head
YAMAMOTO Takashi 4 years ago
parent 102a4467e1
commit 2b7adfe306
  1. 3
      parson.c

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

Loading…
Cancel
Save