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>
This commit is contained in:
Markus Armbruster 2017-02-17 21:38:18 +01:00
parent 4b32e11a59
commit ca6b6e1e68
6 changed files with 21 additions and 44 deletions

View file

@ -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;