Detect garbage near EOF in json_loadf() and json_load_file()

This commit is contained in:
Petri Lehtinen
2009-08-24 20:58:59 +03:00
parent b3e265eb84
commit ee2d164025
2 changed files with 21 additions and 0 deletions

View File

@@ -805,7 +805,17 @@ json_t *json_loadf(FILE *input, json_error_t *error)
return NULL;
result = parse_json(&lex, error);
if(!result)
goto out;
lex_scan(&lex, error);
if(lex.token != TOKEN_EOF) {
error_set(error, &lex, "end of file expected");
json_decref(result);
result = NULL;
}
out:
lex_close(&lex);
return result;
}