[libvirt] [PATCH] Fix memory leak in __virExec

Eric Blake eblake at redhat.com
Sat Apr 30 13:39:01 UTC 2011


On 04/30/2011 05:11 AM, Matthias Bolte wrote:
> Commit e0d014f2379dd made binary potentially allocated on the heap.
> It was freed in the parent in the error path, but not in the success path
> that doesn't goto the cleanup label.
> 
> Found by 'make -C tests valgrind'.
> ---
>  src/util/util.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/src/util/util.c b/src/util/util.c
> index c337aa9..37472bb 100644
> --- a/src/util/util.c
> +++ b/src/util/util.c
> @@ -568,6 +568,10 @@ __virExec(const char *const*argv,
>          }
>  
>          *retpid = pid;
> +
> +        if (binary != argv[0])
> +            VIR_FREE(binary);

ACK.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110430/2a210231/attachment-0001.sig>


More information about the libvir-list mailing list