]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix leak of JSON object for events
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 30 Jun 2011 14:03:31 +0000 (15:03 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 30 Jun 2011 17:04:01 +0000 (18:04 +0100)
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

index 7d286d8f24455b523fe972c9b2042e50af2c1035..81b7f8c8c527fcd95d4184fbbb8707f6b969f121 100644 (file)
@@ -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;
 }