mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-16 21:28:55 +00:00
QMP: Don't leak on connection close
QMP's chardev event callback doesn't call json_message_parser_destroy() on CHR_EVENT_CLOSED. As the call to json_message_parser_init() on CHR_EVENT_OPENED allocates memory, we'are leaking on close. Fix that by just calling json_message_parser_destroy() on CHR_EVENT_CLOSED. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
27a749fb73
commit
47116d1c90
@ -4404,16 +4404,20 @@ static QObject *get_qmp_greeting(void)
|
|||||||
*/
|
*/
|
||||||
static void monitor_control_event(void *opaque, int event)
|
static void monitor_control_event(void *opaque, int event)
|
||||||
{
|
{
|
||||||
if (event == CHR_EVENT_OPENED) {
|
|
||||||
QObject *data;
|
QObject *data;
|
||||||
Monitor *mon = opaque;
|
Monitor *mon = opaque;
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case CHR_EVENT_OPENED:
|
||||||
mon->mc->command_mode = 0;
|
mon->mc->command_mode = 0;
|
||||||
json_message_parser_init(&mon->mc->parser, handle_qmp_command);
|
json_message_parser_init(&mon->mc->parser, handle_qmp_command);
|
||||||
|
|
||||||
data = get_qmp_greeting();
|
data = get_qmp_greeting();
|
||||||
monitor_json_emitter(mon, data);
|
monitor_json_emitter(mon, data);
|
||||||
qobject_decref(data);
|
qobject_decref(data);
|
||||||
|
break;
|
||||||
|
case CHR_EVENT_CLOSED:
|
||||||
|
json_message_parser_destroy(&mon->mc->parser);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user