Re: [PATCHv2] conf: Fix memory leaks in virStoragePoolDefParseSource

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

 



Thanks and pushed now.

----- Original Message -----
From: "Eric Blake" <eblake@xxxxxxxxxx>
To: "Alex Jia" <ajia@xxxxxxxxxx>
Cc: libvir-list@xxxxxxxxxx
Sent: Wednesday, May 9, 2012 11:03:50 PM
Subject: Re:  [PATCHv2] conf: Fix memory leaks in virStoragePoolDefParseSource

On 05/09/2012 04:49 AM, Alex Jia wrote:
> Detected by valgrind. Leaks are introduced in commit 122fa379.
> 
> src/conf/storage_conf.c: fix memory leaks.
> 
> How to reproduce?
> $ make && make -C tests check TESTS=storagepoolxml2xmltest
> $ cd tests && valgrind -v --leak-check=full ./storagepoolxml2xmltest
> 
> actual result:
> ==28571== LEAK SUMMARY:
> ==28571==    definitely lost: 40 bytes in 5 blocks
> ==28571==    indirectly lost: 0 bytes in 0 blocks
> ==28571==      possibly lost: 0 bytes in 0 blocks
> ==28571==    still reachable: 1,054 bytes in 21 blocks
> ==28571==         suppressed: 0 bytes in 0 blocks
> 
> Signed-off-by: Alex Jia <ajia@xxxxxxxxxx>
> ---
>  src/conf/storage_conf.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
> index 0b34f28..188af6d 100644
> --- a/src/conf/storage_conf.c
> +++ b/src/conf/storage_conf.c
> @@ -465,6 +465,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
>          }
>      }
>  
> +    VIR_FREE(nodeset);
>      source->initiator.iqn = virXPathString("string(./initiator/iqn/@name)", ctxt);
>  
>      nsource = virXPathNodeSet("./device", ctxt, &nodeset);

ACK; this properly frees the old use of nodeset before reusing it for a
new use.

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

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