]> git.proxmox.com Git - qemu.git/commitdiff
json-parser: add handling for NULL token list
authorMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 1 Jun 2011 17:15:00 +0000 (12:15 -0500)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 7 Jun 2011 18:52:11 +0000 (13:52 -0500)
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>
json-parser.c

index 58e973bc187aa6e7b3c9f1264eb869bc2febbf6b..849e2156da4e7a3fad8f890370236cb6da9be716 100644 (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);