[libvirt] [PATCH] lxc; Fir memory leak if virSocketAddrGetIPPrefix fails

Laine Stump laine at laine.org
Fri Jul 1 16:02:25 UTC 2016


On 07/01/2016 09:06 AM, Jiri Denemark wrote:
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
>   src/lxc/lxc_container.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index 0d5f16c..65930c9 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -514,18 +514,16 @@ lxcContainerRenameAndEnableInterfaces(virDomainDefPtr vmDef,
>           for (j = 0; j < netDef->guestIP.nips; j++) {
>               virNetDevIPAddrPtr ip = netDef->guestIP.ips[j];
>               int prefix;
> -            char *ipStr = virSocketAddrFormat(&ip->address);
>   
>               if ((prefix = virSocketAddrGetIPPrefix(&ip->address,
>                                                      NULL, ip->prefix)) < 0) {
> -                ipStr = virSocketAddrFormat(&ip->address);
> +                char *ipStr = virSocketAddrFormat(&ip->address);

Oops. The dangers of rebasing and making small changes time after time.

ACK to this, although I'll be pushing the previously reverted (due to my 
mistakenly pushing them after the freeze) patches today, which will 
eliminate this code completely (and replace it with a call to another 
function that doesn't have the leak :-)

>                   virReportError(VIR_ERR_INTERNAL_ERROR,
>                                  _("Failed to determine prefix for IP address '%s'"),
>                                  ipStr);
>                   VIR_FREE(ipStr);
>                   goto cleanup;
>               }
> -            VIR_FREE(ipStr);
>   
>               if (virNetDevIPAddrAdd(newname, &ip->address, NULL, prefix) < 0)
>                   goto cleanup;





More information about the libvir-list mailing list