[PATCH 03/10] Fix crash if OOM occurs when creating virConnectPtr

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

If a OOM error occurs in virGetConnect, this may cause the
virConnectDispose method to de-reference a NULL pointer,
since the close callback will not have been initialized.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/datatypes.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/datatypes.c b/src/datatypes.c
index 940d968..161f1b0 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -164,11 +164,13 @@ virConnectDispose(void *obj)
 
     virURIFree(conn->uri);
 
-    virObjectLock(conn->closeCallback);
-    conn->closeCallback->callback = NULL;
-    virObjectUnlock(conn->closeCallback);
+    if (conn->closeCallback) {
+        virObjectLock(conn->closeCallback);
+        conn->closeCallback->callback = NULL;
+        virObjectUnlock(conn->closeCallback);
 
-    virObjectUnref(conn->closeCallback);
+        virObjectUnref(conn->closeCallback);
+    }
 
     virMutexUnlock(&conn->lock);
     virMutexDestroy(&conn->lock);
-- 
1.8.3.1

--
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]