aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2018-07-03 10:53:40 +0200
committerMarkus Armbruster <armbru@redhat.com>2018-07-03 23:18:56 +0200
commit05f7274c8bd4a958f6673d28bf9bca0a9cf09c76 (patch)
treef3e842c0813211571e5e33aa269dc4156e41d8b1 /monitor.c
parent45434ba47b3e3ccc2ac76674bb3988a152554bf2 (diff)
qmp: Always free QMPRequest with qmp_request_free()
monitor_qmp_dispatch_one() frees a QMPRequest manually, because it needs to keep a reference to ->id. Premature optimization. Take an additional reference so we can use qmp_request_free(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180703085358.13941-15-armbru@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/monitor.c b/monitor.c
index 3cc4b07788..875647f992 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4182,8 +4182,6 @@ static void monitor_qmp_dispatch_one(QMPRequest *req_obj)
id = req_obj->id;
need_resume = req_obj->need_resume;
- g_free(req_obj);
-
old_mon = cur_mon;
cur_mon = mon;
@@ -4192,14 +4190,14 @@ static void monitor_qmp_dispatch_one(QMPRequest *req_obj)
cur_mon = old_mon;
/* Respond if necessary */
- monitor_qmp_respond(mon, rsp, NULL, id);
+ monitor_qmp_respond(mon, rsp, NULL, qobject_ref(id));
/* This pairs with the monitor_suspend() in handle_qmp_command(). */
if (need_resume) {
monitor_resume(mon);
}
- qobject_unref(req);
+ qmp_request_free(req_obj);
}
/*