[libvirt] [PATCH] storage: Avoid leak in virStorageUtilGlusterExtractPoolSources()

Peter Krempa pkrempa at redhat.com
Thu Apr 6 06:29:26 UTC 2017


On Wed, Apr 05, 2017 at 12:40:09 -0400, John Ferlan wrote:
> 
> 
> On 04/05/2017 12:28 PM, Andrea Bolognani wrote:
> > The contents of volname would be leaked if the function were
> > to be passed an invalid pooltype by the caller.
> > 
> > Make sure the memory is released instead.
> > ---
> > Initializing volname to NULL is strictly speaking not
> > necessary, but I like it better that way :)
> > 
> >  src/storage/storage_util.c | 12 +++++++++---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> > 
> 
> This could be "as easy as" just adding a VIR_FREE(volname) in the "}
> else {" case prior to virReportError and goto cleanup;
> 
> 
> If you went with this option, then VIR_STEAL_PTR(src->dir, volname); and
> VIR_STEAL_PTR(src->name, volname); instead of inlining.

I vote for this.

> 
> And as some would say the comment is "obvious".

And for this.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170406/5242dee3/attachment-0001.sig>


More information about the libvir-list mailing list