[libvirt] [libvirt-glib PATCHv4 2/7] gobject: Plug 2 virConnect leaks

Christophe Fergeau cfergeau at redhat.com
Mon Jul 6 16:55:48 UTC 2015


Please be a bit more verbose in the commit log as to what the leak is.
(a virConnect reference is leaked in error cases, the unref is moved
after the label we jump to on errors to avoid the leak)

Looks good otherwise,

Christophe

On Wed, Jul 01, 2015 at 09:40:46PM +0100, Zeeshan Ali (Khattak) wrote:
> ---
>  libvirt-gobject/libvirt-gobject-connection.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
> index 1576906..dddbd3a 100644
> --- a/libvirt-gobject/libvirt-gobject-connection.c
> +++ b/libvirt-gobject/libvirt-gobject-connection.c
> @@ -748,7 +748,6 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn,
>      if (priv->domains)
>          g_hash_table_unref(priv->domains);
>      priv->domains = doms;
> -    virConnectClose(vconn);
>      g_mutex_unlock(priv->lock);
>  
>      ret = TRUE;
> @@ -759,6 +758,8 @@ cleanup:
>              virDomainFree(domains[i]);
>          free(domains);
>      }
> +    if (vconn != NULL)
> +        virConnectClose(vconn);
>      return ret;
>  }
>  
> @@ -835,7 +836,6 @@ gboolean gvir_connection_fetch_storage_pools(GVirConnection *conn,
>      if (priv->pools)
>          g_hash_table_unref(priv->pools);
>      priv->pools = pools;
> -    virConnectClose(vconn);
>      g_mutex_unlock(priv->lock);
>  
>      ret = TRUE;
> @@ -846,6 +846,8 @@ cleanup:
>              virStoragePoolFree(vpools[i]);
>          free(vpools);
>      }
> +    if (vconn != NULL)
> +        virConnectClose(vconn);
>      return ret;
>  }
>  
> -- 
> 2.4.3
> 
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150706/4dcaae62/attachment-0001.sig>


More information about the libvir-list mailing list