[libvirt] [PATCH v2 1/3] libxl: add support for multiple IP addresses

Marek Marczykowski-Górecki marmarek at invisiblethingslab.com
Mon Dec 11 13:37:38 UTC 2017


On Mon, Dec 11, 2017 at 07:58:54AM -0500, John Ferlan wrote:
> > +char *
> > +xenMakeIPList(virNetDevIPInfoPtr guestIP)
> > +{
> > +    size_t i;
> > +    char **address_array;
> > +    char *ret = NULL;
> > +
> > +    if (VIR_ALLOC_N(address_array, guestIP->nips + 1) < 0)
> > +        return NULL;
> > +
> > +    for (i = 0; i < guestIP->nips; i++) {
> > +        address_array[i] = virSocketAddrFormat(&guestIP->ips[i]->address);
> > +        if (!address_array[i])
> > +            goto cleanup;
> > +    }
> > +    address_array[guestIP->nips] = NULL;
> > +
> > +    ret = virStringListJoin((const char**)address_array, " ");
> > +
> > + cleanup:
> > +    while (i > 0)
> > +        VIR_FREE(address_array[--i]);
> 
> Coverity notes that address_array is leaked.  May I sugguest
> "virStringListFree()" on address array?

Then I should initialize each entry to NULL first (which will be
overridden a moment later). Is it ok?

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20171211/4ffeca2b/attachment-0001.sig>


More information about the libvir-list mailing list