Re: [PATCH] qemu: fix lastError memory leak

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

 



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@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);

Shouldn't we just reset mon->lastError unconditionally?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]