More checks for json number parsing
This commit is contained in:
parent
63cde2272b
commit
ba92eed1f5
16
json.cpp.rl
16
json.cpp.rl
@ -121,13 +121,19 @@ struct parse_context {
|
||||
|
||||
action new_number {
|
||||
check_hard (!nodestack.empty ());
|
||||
check (!nodestack.back ().value);
|
||||
|
||||
|
||||
parse_context &back = nodestack.back ();
|
||||
check (!back.value);
|
||||
check_hard (back.start);
|
||||
check_hard (back.stop);
|
||||
check_hard (back.start <= back.stop);
|
||||
|
||||
errno = 0;
|
||||
double value = strtod (nodestack.back ().start, NULL);
|
||||
if (errno)
|
||||
char *end;
|
||||
double value = strtod (back.start, &end);
|
||||
if (end == back.start || errno)
|
||||
throw parse_error ("unable to parse number");
|
||||
nodestack.back ().value = new json::number (value);
|
||||
back.value = new json::number (value);
|
||||
}
|
||||
|
||||
action new_null {
|
||||
|
Loading…
Reference in New Issue
Block a user