[balsa] Do not seg fault on delayed exit



commit 1f1d4d7e970b4ebbd51eb763bf2d052901646fe1
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Jun 5 11:36:17 2018 -0400

    Do not seg fault on delayed exit
    
    * libbalsa/mailbox.c
      (lbm_changed_schedule_idle): ref the mailbox
      (lbm_changed_idle_cb): and unref it;
    * src/main-window.c (check_new_messages_real): check for
      balsa_app.mblist_tree_store == NULL, and do not dereference it.

 ChangeLog          | 10 ++++++++++
 libbalsa/mailbox.c |  7 +++++--
 src/main-window.c  |  6 +++++-
 3 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f4a0f470..e9f49ecb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2018-06-05  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Do not seg fault on delayed exit
+
+       * libbalsa/mailbox.c
+       (lbm_changed_schedule_idle): ref the mailbox
+       (lbm_changed_idle_cb): and unref it;
+       * src/main-window.c (check_new_messages_real): check for
+       balsa_app.mblist_tree_store == NULL, and do not dereference it.
+
 2018-06-01  Pawel Salek  <pawsa0 gmail com>
 
        * NEWS, configure.ac: release balsa-2.5.6
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 59bf9a47..40feb046 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -717,7 +717,10 @@ lbm_changed_idle_cb(LibBalsaMailbox * mailbox)
     g_signal_emit(mailbox, libbalsa_mailbox_signals[CHANGED], 0);
     mailbox->changed_idle_id = 0;
     libbalsa_unlock_mailbox(mailbox);
-    return FALSE;
+
+    g_object_unref(mailbox);
+
+    return G_SOURCE_REMOVE;
 }
 
 static void
@@ -726,7 +729,7 @@ lbm_changed_schedule_idle(LibBalsaMailbox * mailbox)
     libbalsa_lock_mailbox(mailbox);
     if (!mailbox->changed_idle_id)
         mailbox->changed_idle_id =
-            g_idle_add((GSourceFunc) lbm_changed_idle_cb, mailbox);
+            g_idle_add((GSourceFunc) lbm_changed_idle_cb, g_object_ref(mailbox));
     libbalsa_unlock_mailbox(mailbox);
 }
 
diff --git a/src/main-window.c b/src/main-window.c
index 1e0d5b0b..c0a51812 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -3325,7 +3325,10 @@ check_new_messages_real(BalsaWindow * window, gboolean background_check)
     if (window && !BALSA_IS_WINDOW(window))
         return;
 
-    list = NULL;
+    if (balsa_app.mblist_tree_store == NULL)
+        /* Quitt'n time! */
+        return;
+
     /*  Only Run once -- If already checking mail, return.  */
     if (!g_atomic_int_dec_and_test(&checking_mail)) {
        g_atomic_int_inc(&checking_mail);
@@ -3341,6 +3344,7 @@ check_new_messages_real(BalsaWindow * window, gboolean background_check)
     if (window)
         bw_action_set_enabled(window, "get-new-mail", FALSE);
 
+    list = NULL;
     gtk_tree_model_foreach(GTK_TREE_MODEL(balsa_app.mblist_tree_store),
                           (GtkTreeModelForeachFunc) bw_add_mbox_to_checklist,
                           &list);


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