[evolution-ews] Bug 738987 - Crash under e_ews_notification_unsubscribe_folder_sync()



commit 8e3c2f5dd19177b118488cf626437df92c21544f
Author: Milan Crha <mcrha redhat com>
Date:   Thu Oct 30 19:31:31 2014 +0100

    Bug 738987 - Crash under e_ews_notification_unsubscribe_folder_sync()

 src/server/e-ews-connection.c   |    7 ++++---
 src/server/e-ews-notification.c |   12 +++++++++++-
 2 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index 05a96ee..ad14f92 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -9403,14 +9403,15 @@ e_ews_connection_disable_notifications_sync (EEwsConnection *cnc,
 
        e_ews_notification_stop_listening_sync (cnc->priv->notification);
 
-       g_clear_object (&cnc->priv->notification);
-
        g_slist_free_full (cnc->priv->subscribed_folders, g_free);
        cnc->priv->subscribed_folders = NULL;
 
        g_hash_table_foreach (cnc->priv->subscriptions, ews_connection_build_subscribed_folders_list, cnc);
-       if (cnc->priv->subscribed_folders != NULL)
+       if (cnc->priv->subscribed_folders != NULL) {
                e_ews_notification_start_listening_sync (cnc->priv->notification, 
cnc->priv->subscribed_folders);
+       } else {
+               g_clear_object (&cnc->priv->notification);
+       }
 
 exit:
        NOTIFICATION_UNLOCK (cnc);
diff --git a/src/server/e-ews-notification.c b/src/server/e-ews-notification.c
index 1b5e37f..6e73ccf 100644
--- a/src/server/e-ews-notification.c
+++ b/src/server/e-ews-notification.c
@@ -202,6 +202,7 @@ ews_notification_dispose (GObject *object)
                g_signal_handlers_disconnect_by_func (
                        priv->soup_session,
                        ews_notification_authenticate, object);
+               g_clear_object (&priv->soup_session);
        }
 
        if (priv->cancellable != NULL)
@@ -318,6 +319,10 @@ e_ews_notification_subscribe_folder_sync (EEwsNotification *notification,
        g_return_val_if_fail (notification != NULL, FALSE);
        g_return_val_if_fail (notification->priv != NULL, FALSE);
 
+       /* Can happen during process shutdown */
+       if (!notification->priv->connection)
+               return FALSE;
+
        msg = e_ews_message_new_with_header (
                e_ews_connection_get_uri (notification->priv->connection),
                e_ews_connection_get_impersonate_user (notification->priv->connection),
@@ -435,6 +440,10 @@ e_ews_notification_unsubscribe_folder_sync (EEwsNotification *notification,
        g_return_val_if_fail (notification != NULL, FALSE);
        g_return_val_if_fail (notification->priv != NULL, FALSE);
 
+       /* Can happen during process shutdown */
+       if (!notification->priv->connection)
+               return FALSE;
+
        msg = e_ews_message_new_with_header (
                e_ews_connection_get_uri (notification->priv->connection),
                e_ews_connection_get_impersonate_user (notification->priv->connection),
@@ -616,7 +625,8 @@ ews_notification_fire_events_from_response (EEwsNotification *notification,
        }
 
        if (events != NULL) {
-               g_signal_emit_by_name (notification->priv->connection, "server-notification", events);
+               if (notification->priv->connection)
+                       g_signal_emit_by_name (notification->priv->connection, "server-notification", events);
                g_slist_free_full (events, (GDestroyNotify) e_ews_notification_event_free);
        }
 }


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