diff options
author | 2011-06-30 15:03:31 +0100 | |
---|---|---|
committer | 2011-06-30 18:04:01 +0100 | |
commit | 5ab8746f69af4f4c98f24b6ce4057271c88ac0b5 (patch) | |
tree | 281c2236d4ec1944373afc5db742fae450aa789e | |
parent | Remove bogus warning message in JSON code (diff) | |
download | libvirt-5ab8746f69af4f4c98f24b6ce4057271c88ac0b5.tar.gz libvirt-5ab8746f69af4f4c98f24b6ce4057271c88ac0b5.tar.bz2 libvirt-5ab8746f69af4f4c98f24b6ce4057271c88ac0b5.zip |
Fix leak of JSON object for events
The event handler functions do not free the virJSONValuePtr
object. Every event received from a VM thus caused a memory
leak
* src/qemu/qemu_monitor_json.c: Fix leak of event object
-rw-r--r-- | src/qemu/qemu_monitor_json.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7d286d8f2..81b7f8c8c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -122,7 +122,6 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon, if (virJSONValueObjectHasKey(obj, "QMP") == 1) { ret = 0; - virJSONValueFree(obj); } else if (virJSONValueObjectHasKey(obj, "event") == 1) { ret = qemuMonitorJSONIOProcessEvent(mon, obj); } else if (virJSONValueObjectHasKey(obj, "error") == 1 || @@ -130,6 +129,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon, if (msg) { msg->rxObject = obj; msg->finished = 1; + obj = NULL; ret = 0; } else { qemuReportError(VIR_ERR_INTERNAL_ERROR, @@ -141,8 +141,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon, } cleanup: - if (ret < 0) - virJSONValueFree(obj); + virJSONValueFree(obj); return ret; } |