[balsa] balsa-message: Do not crash



commit 14f0e61cff6570ad2968d79d055a41afca0ab4aa
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sat Jun 6 16:47:46 2020 -0400

    balsa-message: Do not crash
    
    if the message part is changed while the find-in-message bar is active.
    
    * src/balsa-message.c (bm_find_entry_changed_cb):

 ChangeLog           |  9 +++++++++
 src/balsa-message.c | 15 +++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fcf87d2c3..4100126c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-06-06  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       balsa-message: Do not crash
+
+       if the message part is changed while the find-in-message bar is
+       active.
+
+       * src/balsa-message.c (bm_find_entry_changed_cb):
+
 2020-06-06  Peter Bloomfield  <pbloomfield bellsouth net>
 
        toolbar-factory: Stop using direct access to GdkEvent structs
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 2bc9fcb2b..2c4f5b646 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -416,13 +416,20 @@ bm_find_cb(const gchar * text, gboolean found, gpointer data)
 static void
 bm_find_entry_changed_cb(GtkEditable * editable, gpointer data)
 {
-    const gchar *text = gtk_entry_get_text(GTK_ENTRY(editable));
     BalsaMessage *balsa_message = data;
-    BalsaMimeWidget *mime_widget = balsa_message->current_part->mime_widget;
-    GtkWidget *widget = balsa_mime_widget_text_get_text_widget(BALSA_MIME_WIDGET_TEXT(mime_widget));
-    gboolean found = FALSE;
+    const gchar *text;
+    BalsaMimeWidget *mime_widget;
+    GtkWidget *widget;
+
+    if (balsa_message->current_part == NULL)
+        return;
+
+    mime_widget = balsa_message->current_part->mime_widget;
+    widget = balsa_mime_widget_text_get_text_widget(BALSA_MIME_WIDGET_TEXT(mime_widget));
+    text = gtk_entry_get_text(GTK_ENTRY(editable));
 
     if (GTK_IS_TEXT_VIEW(widget)) {
+        gboolean found = FALSE;
         GtkTextView *text_view = GTK_TEXT_VIEW(widget);
         GtkTextBuffer *buffer = gtk_text_view_get_buffer(text_view);
         GtkTextIter match_begin, match_end;


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