Skip to content

Commit

Permalink
Fix parsing JSON numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Barenboim committed Oct 20, 2023
1 parent c152bb4 commit ea89c7b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/util/json_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,18 @@ static int __parse_json_number(const char *cursor, const char **end,
if (*p == '-')
p++;

if (!isdigit(*p))
return -2;

if (*p == '0' && (isdigit(p[1]) || p[1] == 'X' || p[1] == 'x'))
return -2;

while (isdigit(*++p))
;

if (*p == '.' && !isdigit(*(p + 1)))
return -2;

*num = strtod(cursor, (char **)end);
if (*end == cursor)
return -2;
Expand Down

0 comments on commit ea89c7b

Please sign in to comment.