diff options
author | Michael Roth <mdroth@linux.vnet.ibm.com> | 2011-06-01 12:15:00 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-06-07 13:52:11 -0500 |
commit | c1990ebfa11265d3aa9b6a4d5d1a02bd3f9ac5c6 (patch) | |
tree | d658e474c4f362bc2a0bcdb12ab2d9abc51bb2c4 | |
parent | 5e2dafeb198ba095ea784a97b44011ce2ed03511 (diff) | |
download | hqemu-c1990ebfa11265d3aa9b6a4d5d1a02bd3f9ac5c6.zip hqemu-c1990ebfa11265d3aa9b6a4d5d1a02bd3f9ac5c6.tar.gz |
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>
-rw-r--r-- | json-parser.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/json-parser.c b/json-parser.c index 58e973b..849e215 100644 --- a/json-parser.c +++ b/json-parser.c @@ -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); |