More checks for json number parsing

This commit is contained in:
Danny Robson 2012-05-11 12:17:40 +10:00
parent 63cde2272b
commit ba92eed1f5

View File

@ -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 {