Skip to content

Commit

Permalink
object-add: don't create return value if failed
Browse files Browse the repository at this point in the history
No need to return an empty value from object-add (it would also leak
if the command failed).  While at it, remove the "if" around object_unref
since object_unref handles NULL arguments just fine.

Reported-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20200325184723.2029630-4-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Apr 2, 2020
1 parent b3fbb32 commit 7f5d9b2
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions qom/qom-qmp-cmds.c
Expand Up @@ -285,10 +285,7 @@ void qmp_object_add(QDict *qdict, QObject **ret_data, Error **errp)
v = qobject_input_visitor_new(QOBJECT(qdict));
obj = user_creatable_add_type(type, id, qdict, v, errp);
visit_free(v);
if (obj) {
object_unref(obj);
}
*ret_data = QOBJECT(qdict_new());
object_unref(obj);
}

void qmp_object_del(const char *id, Error **errp)
Expand Down

0 comments on commit 7f5d9b2

Please sign in to comment.