load: Parse a badly put - sign correctly

Thanks to Manolis Delakis for reporting.
This commit is contained in:
Petri Lehtinen 2009-10-29 15:42:05 +02:00
parent f243930b68
commit d3959a8ce7
3 changed files with 37 additions and 3 deletions

View File

@ -418,11 +418,15 @@ static int lex_scan_number(lex_t *lex, char c, json_error_t *error)
goto out;
}
}
else /* c != '0' */ {
else if(isdigit(c)) {
c = lex_get_save(lex, error);
while(isdigit(c))
c = lex_get_save(lex, error);
}
else {
lex_unget_unsave(lex, c);
goto out;
}
if(c != '.' && c != 'E' && c != 'e') {
long value;

17
test/testdata/invalid vendored
View File

@ -167,7 +167,22 @@ too big negative integer near '-123123123123123'
====
1
invalid token near 'troo'
==== invalid-escap ====
==== minus-sign-without-number ====
[-foo]
====
1
invalid token near '-'
==== invalid-negative-integerr ====
[-123foo]
====
1
']' expected near 'foo'
==== invalid-negative-real ====
[-123.123foo]
====
1
']' expected near 'foo'
==== invalid-escape ====
["\a <-- invalid escape"]
====
1

View File

@ -167,7 +167,22 @@ too big negative integer near '-123123123123123'
====
1
invalid token near 'troo'
==== invalid-escap ====
==== minus-sign-without-number ====
[-foo]
====
1
invalid token near '-'
==== invalid-negative-integerr ====
[-123foo]
====
1
']' expected near 'foo'
==== invalid-negative-real ====
[-123.123foo]
====
1
']' expected near 'foo'
==== invalid-escape ====
["\a <-- invalid escape"]
====
1