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