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

[libvirt] [PATCH] xenapi: Check for valid private data in xenapiSessionErrorHandle



---
 src/xenapi/xenapi_utils.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 4b9a6d8..bfd53ed 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -374,12 +374,12 @@ xenapiSessionErrorHandle(virConnectPtr conn, virErrorNumber errNum,
                          const char *buf, const char *filename, const char *func,
                          size_t lineno)
 {
-    xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+    struct _xenapiPrivate *priv = conn->privateData;
 
-    if (buf == NULL) {
-        char *ret = returnErrorFromSession(session);
+    if (buf == NULL && priv != NULL && priv->session != NULL) {
+        char *ret = returnErrorFromSession(priv->session);
         virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), ret);
-        xen_session_clear_error(session);
+        xen_session_clear_error(priv->session);
         VIR_FREE(ret);
     } else {
         virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), buf);
-- 
1.6.3.3


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