
On 12/02/2013 06:25 AM, Wangyufei (James) wrote:
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.
Do you have a valgrind trace of the leak? It's not strictly required, but having it would help prove that this is the right fix.
Signed-off-by: Zhou Yimin <zhouyimin@huawei.com> --- 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);
Shouldn't we just reset mon->lastError unconditionally? -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org