[PATCH] qemu: fix lastError memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When an error occurred in qemuMonitorIO, it will be saved in mon->lastError,
but the memory which mon->lastError.message, mon->lastError.str1,
mon->lastError.str2 and mon->lastError.str3 will not be freed at last.
The same bug happened in qemuAgentIO. So I add the following code to fix it.

Signed-off-by: Zhou Yimin <zhouyimin@xxxxxxxxxx>
---
 src/qemu/qemu_agent.c   |    2 ++
 src/qemu/qemu_monitor.c |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 2cd0ccc..475b43e 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -161,6 +161,8 @@ static void qemuAgentDispose(void *obj)
         (mon->cb->destroy)(mon, mon->vm);
     virCondDestroy(&mon->notify);
     VIR_FREE(mon->buffer);
+    if (mon->lastError.code != VIR_ERR_OK)
+        virResetError(&mon->lastError);
 }
 
 static int
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 1514715..df72c5d 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -263,6 +263,8 @@ static void qemuMonitorDispose(void *obj)
     virJSONValueFree(mon->options);
     VIR_FREE(mon->balloonpath);
     VIR_FORCE_CLOSE(mon->logfd);
+    if (mon->lastError.code != VIR_ERR_OK)
+        virResetError(&mon->lastError);
 }
 
 
-- 
1.7.3.1.msysgit.0

Best Regards,
-WangYufei


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]