[evolution-data-server] CamelNetworkService: Check for non-NULL session



commit c93070c89b27c04fce8db07683c24fe15bb9f33a
Author: Milan Crha <mcrha redhat com>
Date:   Thu Feb 26 10:49:11 2015 +0100

    CamelNetworkService: Check for non-NULL session
    
    It can happen that the session is NULL, for example when checking
    for supported authentication types, thus check for that state and
    avoid actions which require valid session object.

 camel/camel-network-service.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/camel/camel-network-service.c b/camel/camel-network-service.c
index 76a8d76..5d9741e 100644
--- a/camel/camel-network-service.c
+++ b/camel/camel-network-service.c
@@ -215,6 +215,9 @@ network_service_accept_certificate_cb (GTlsConnection *connection,
        gchar *host;
 
        session = camel_service_ref_session (CAMEL_SERVICE (service));
+       if (!session)
+               return FALSE;
+
        settings = camel_service_ref_settings (CAMEL_SERVICE (service));
 
        network_settings = CAMEL_NETWORK_SETTINGS (settings);
@@ -309,13 +312,15 @@ network_service_notify_host_reachable (CamelNetworkService *service)
 
        session = camel_service_ref_session (CAMEL_SERVICE (service));
 
-       camel_session_idle_add (
-               session, G_PRIORITY_DEFAULT_IDLE,
-               network_service_notify_host_reachable_cb,
-               g_object_ref (service),
-               (GDestroyNotify) g_object_unref);
+       if (session) {
+               camel_session_idle_add (
+                       session, G_PRIORITY_DEFAULT_IDLE,
+                       network_service_notify_host_reachable_cb,
+                       g_object_ref (service),
+                       (GDestroyNotify) g_object_unref);
 
-       g_object_unref (session);
+               g_object_unref (session);
+       }
 }
 
 static void
@@ -415,6 +420,9 @@ network_service_update_host_reachable (CamelNetworkService *service)
        priv = CAMEL_NETWORK_SERVICE_GET_PRIVATE (service);
 
        session = camel_service_ref_session (CAMEL_SERVICE (service));
+       if (!session)
+               return;
+
        if (!camel_session_get_online (session)) {
                g_object_unref (session);
                return;


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