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

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

 



A virConnect reference is leaked in error cases. This patch moves the
unref after the label we jump to on errors, to avoid this leak.
---
 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 e088427..02eef7b 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@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]