]> granicus.if.org Git - mutt/commitdiff
I've attached a patch for bug number 1036, as reported at
authorDan Fandrich <dan@coneharvesters.com>
Wed, 3 Sep 2003 17:22:09 +0000 (17:22 +0000)
committerDan Fandrich <dan@coneharvesters.com>
Wed, 3 Sep 2003 17:22:09 +0000 (17:22 +0000)
http://bugs.guug.de/db/pa/lmutt.html ("segfault when more than one
msg is postponed").  This is a patch against mutt 1.4.1.

As it was previously left, no one could reproduce it.  The problem
occurs because sorting is disabled when opening the postponed
folder, but the Sort global variable still tells mutt to use
whatever sorting algorithm the $sort config option indicates.
Eventually, the code would get to mutt_messages_in_thread and try to
dereference a NULL thread object, causing the segfault.

postpone.c

index 53a42300e1359af0009f4b6b9f9e672de29a3d88..ac61107904001f9c7dba9d1a17108325b4567869 100644 (file)
@@ -23,6 +23,7 @@
 #include "mime.h"
 #include "mailbox.h"
 #include "mapping.h"
+#include "sort.h"
 #ifdef USE_IMAP
 #include "mx.h"
 #include "imap.h"
@@ -153,6 +154,7 @@ static HEADER *select_msg (void)
   MUTTMENU *menu;
   int i, done=0, r=-1;
   char helpstr[SHORT_STRING];
+  short orig_sort;
 
   menu = mutt_new_menu ();
   menu->make_entry = post_entry;
@@ -162,6 +164,12 @@ static HEADER *select_msg (void)
   menu->data = PostContext;
   menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_POST, PostponeHelp);
 
+  /* The postponed mailbox is setup to have sorting disabled, but the global
+   * Sort variable may indicate something different.   Sorting has to be
+   * disabled while the postpone menu is being displayed. */
+  orig_sort = Sort;
+  Sort = SORT_ORDER;
+  
   while (!done)
   {
     switch (i = mutt_menuLoop (menu))
@@ -197,6 +205,7 @@ static HEADER *select_msg (void)
     }
   }
 
+  Sort = orig_sort;
   mutt_menuDestroy (&menu);
   return (r > -1 ? PostContext->hdrs[r] : NULL);
 }