[libvirt] [PATCH] qemu: fix lastError memory leak
Eric Blake
eblake at redhat.com
Mon Dec 2 22:45:06 UTC 2013
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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131202/3b59b7a4/attachment-0001.sig>
More information about the libvir-list
mailing list