summary refs log tree commit diff stats
path: root/block.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-02-17 21:38:18 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-02-22 19:52:01 +0100
commitca6b6e1e68ac44b2e8895da10dd1c80dc03d08b7 (patch)
tree3e820280a3eb45a68186eaec2f46fba2b1fe63b8 /block.c
parent4b32e11a59e34c5cf570c1fd102a78d9351e71f5 (diff)
downloadfocaccia-qemu-ca6b6e1e68ac44b2e8895da10dd1c80dc03d08b7.tar.gz
focaccia-qemu-ca6b6e1e68ac44b2e8895da10dd1c80dc03d08b7.zip
Don't check qobject_type() before qobject_to_qdict()
qobject_to_qdict(obj) returns NULL when obj isn't a QDict.  Check
that instead of qobject_type(obj) == QTYPE_QDICT.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1487363905-9480-8-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/block.c b/block.c
index 743c349100..3c36af5e76 100644
--- a/block.c
+++ b/block.c
@@ -1169,13 +1169,13 @@ static QDict *parse_json_filename(const char *filename, Error **errp)
         return NULL;
     }
 
-    if (qobject_type(options_obj) != QTYPE_QDICT) {
+    options = qobject_to_qdict(options_obj);
+    if (!options) {
         qobject_decref(options_obj);
         error_setg(errp, "Invalid JSON object given");
         return NULL;
     }
 
-    options = qobject_to_qdict(options_obj);
     qdict_flatten(options);
 
     return options;