aboutsummaryrefslogtreecommitdiff
path: root/hmp.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-05-07 09:53:51 +0200
committerLuiz Capitulino <lcapitulino@redhat.com>2014-05-15 14:00:46 -0400
commitf9f3a5ecde4cb636d8eb43edc0d097bd364ffe75 (patch)
treee9c8956d719caa9e080adc76423f36200ed42c3c /hmp.c
parentbe3c771796cb5ca4e7de2e04ed3cd2e3b6b76185 (diff)
hmp: Call visit_end_struct() after visit_start_struct() succeeds
When visit_start_struct() succeeds, visit_end_struct() must be called. hmp_object_add() doesn't when a member visit fails. As far as I can tell, the opts visitor copes okay with the misuse. Fix it anyway. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'hmp.c')
-rw-r--r--hmp.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/hmp.c b/hmp.c
index 5c4d612294..a9d0236cc3 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1388,6 +1388,7 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)
void hmp_object_add(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
+ Error *err_end = NULL;
QemuOpts *opts;
char *type = NULL;
char *id = NULL;
@@ -1411,24 +1412,23 @@ void hmp_object_add(Monitor *mon, const QDict *qdict)
qdict_del(pdict, "qom-type");
visit_type_str(opts_get_visitor(ov), &type, "qom-type", &err);
if (err) {
- goto out_clean;
+ goto out_end;
}
qdict_del(pdict, "id");
visit_type_str(opts_get_visitor(ov), &id, "id", &err);
if (err) {
- goto out_clean;
+ goto out_end;
}
object_add(type, id, pdict, opts_get_visitor(ov), &err);
- if (err) {
- goto out_clean;
- }
- visit_end_struct(opts_get_visitor(ov), &err);
- if (err) {
+
+out_end:
+ visit_end_struct(opts_get_visitor(ov), &err_end);
+ if (!err && err_end) {
qmp_object_del(id, NULL);
}
-
+ error_propagate(&err, err_end);
out_clean:
opts_visitor_cleanup(ov);