From: "Daniel P. Berrange" <berrange(a)redhat.com>
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(a)redhat.com>
---
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