Skip to content

Commit

Permalink
qapi: Make QObject input visitor set *list reliably
Browse files Browse the repository at this point in the history
qobject_input_start_struct() sets *list, except when it fails because
qobject_input_get_object() fails, i.e. the input object doesn't exist.

All the other input visitor start_struct(), start_list(),
start_alternate() always set *obj / *list.

Change qobject_input_start_struct() to match.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1488544368-30622-14-git-send-email-armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
  • Loading branch information
Markus Armbruster committed Mar 5, 2017
1 parent b8874fb commit 58561c2
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions qapi/qobject-input-visitor.c
Expand Up @@ -196,25 +196,21 @@ static void qobject_input_start_list(Visitor *v, const char *name,
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
const QListEntry *entry;

if (list) {
*list = NULL;
}
if (!qobj) {
return;
}
if (qobject_type(qobj) != QTYPE_QLIST) {
if (list) {
*list = NULL;
}
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"list");
return;
}

entry = qobject_input_push(qiv, qobj, list);
if (list) {
if (entry) {
*list = g_malloc0(size);
} else {
*list = NULL;
}
if (entry && list) {
*list = g_malloc0(size);
}
}

Expand Down

0 comments on commit 58561c2

Please sign in to comment.