Print correct error message on premature end of array

This commit is contained in:
Petri Lehtinen 2009-06-21 16:04:43 +03:00
parent ae5ed3ff70
commit dc9b954b62
1 changed files with 16 additions and 14 deletions

View File

@ -359,8 +359,10 @@ static json_t *json_parse_array(json_lex *lex, json_error_t *error)
return NULL;
json_lex_scan(lex);
if(lex->token != ']') {
while(1) {
if(lex->token == ']')
return array;
while(lex->token) {
json_t *elem = json_parse(lex, error);
if(!elem)
goto error;
@ -376,7 +378,7 @@ static json_t *json_parse_array(json_lex *lex, json_error_t *error)
json_lex_scan(lex);
}
}
if(lex->token != ']') {
json_set_error(error, lex, "']' expected");