[libvirt] [PATCH] Fix leak of JSON object for events
Eric Blake
eblake at redhat.com
Thu Jun 30 14:18:53 UTC 2011
On 06/30/2011 08:10 AM, Daniel P. Berrange wrote:
> 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
> ---
> src/qemu/qemu_monitor_json.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)
Nice catch.
>
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 7d286d8..81b7f8c 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);
ACK.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110630/f91e30fc/attachment-0001.sig>
More information about the libvir-list
mailing list