# HG changeset patch
# User Andrew Gaul <[email protected]>
# Date 1348464567 25200
# Branch HEAD
# Node ID 3d3f1fb09ef6dcb52393e4d68b0a8d1e2242efea
# Parent  70810a88ce9feb66d5c74e7ec3f2a633bd8b5312
Guard against NULL dereference in mutt_parent_message

Seen when switching IMAP accounts:

Program terminated with signal 11, Segmentation fault.
#0  0x000000000048dbfa in mutt_parent_message (ctx=0x2cb9870, hdr=0x0)
    at thread.c:1087
1087      for (thread = hdr->thread->parent; thread; thread = thread->parent)

(gdb) bt
#0  0x000000000048dbfa in mutt_parent_message (ctx=0x2cb9870, hdr=0x0)
    at thread.c:1087
#1  0x00000000004236a9 in resort_index (menu=0x271bed0) at curs_main.c:396
#2  0x000000000042384e in mutt_index_menu () at curs_main.c:456
#3  0x0000000000449b13 in main (argc=1, argv=0x7fff68a4e528) at main.c:1020

(gdb) print hdr
$1 = (HEADER *) 0x0

diff -r 70810a88ce9f -r 3d3f1fb09ef6 thread.c
--- a/thread.c  Sun Jul 22 11:15:30 2012 -0700
+++ b/thread.c  Sun Sep 23 22:29:27 2012 -0700
@@ -1078,6 +1078,10 @@
 {
   THREAD *thread;
 
+  if (hdr == NULL) {
+    goto out;
+  }
+
   if ((Sort & SORT_MASK) != SORT_THREADS)
   {
     mutt_error _("Threading is not enabled.");
@@ -1097,7 +1101,8 @@
       }
     }
   }
-  
+
+out:
   mutt_error _("Parent message is not available.");
   return (-1);
 }

Reply via email to