summaryrefslogtreecommitdiff
path: root/json-parser.c
diff options
context:
space:
mode:
authorMichael Roth <mdroth@linux.vnet.ibm.com>2011-06-01 12:15:00 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2011-06-07 13:52:11 -0500
commitc1990ebfa11265d3aa9b6a4d5d1a02bd3f9ac5c6 (patch)
treed658e474c4f362bc2a0bcdb12ab2d9abc51bb2c4 /json-parser.c
parent5e2dafeb198ba095ea784a97b44011ce2ed03511 (diff)
downloadqemu-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>
Diffstat (limited to 'json-parser.c')
-rw-r--r--json-parser.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/json-parser.c b/json-parser.c
index 58e973bc18..849e2156da 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);