aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qom/qom-qmp-cmds.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 49db926fcc..435193b036 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -247,26 +247,22 @@ void qmp_object_add(QDict *qdict, QObject **ret_data, Error **errp)
QDict *pdict;
Visitor *v;
Object *obj;
- const char *type;
- const char *id;
+ g_autofree char *type = NULL;
+ g_autofree char *id = NULL;
- type = qdict_get_try_str(qdict, "qom-type");
+ type = g_strdup(qdict_get_try_str(qdict, "qom-type"));
if (!type) {
error_setg(errp, QERR_MISSING_PARAMETER, "qom-type");
return;
- } else {
- type = g_strdup(type);
- qdict_del(qdict, "qom-type");
}
+ qdict_del(qdict, "qom-type");
- id = qdict_get_try_str(qdict, "id");
+ id = g_strdup(qdict_get_try_str(qdict, "id"));
if (!id) {
error_setg(errp, QERR_MISSING_PARAMETER, "id");
return;
- } else {
- id = g_strdup(id);
- qdict_del(qdict, "id");
}
+ qdict_del(qdict, "id");
props = qdict_get(qdict, "props");
if (props) {