sim-card
/
qemu
Archived
10
0
Fork 0

json-parser: add handling for NULL token list

Currently a NULL token list will crash the parser, instead we have it
pass back a NULL QObject.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Michael Roth 2011-06-01 12:15:00 -05:00 committed by Anthony Liguori
parent 5e2dafeb19
commit c1990ebfa1
1 changed files with 5 additions and 1 deletions

View File

@ -633,9 +633,13 @@ QObject *json_parser_parse(QList *tokens, va_list *ap)
QObject *json_parser_parse_err(QList *tokens, va_list *ap, Error **errp)
{
JSONParserContext ctxt = {};
QList *working = qlist_copy(tokens);
QList *working;
QObject *result;
if (!tokens) {
return NULL;
}
working = qlist_copy(tokens);
result = parse_value(&ctxt, &working, ap);
QDECREF(working);