From 3d8baab528e370cabb12baf9102d668cead809a7 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 3 Sep 2003 17:22:09 +0000 Subject: [PATCH] I've attached a patch for bug number 1036, as reported at 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/postpone.c b/postpone.c index 53a42300..ac611079 100644 --- a/postpone.c +++ b/postpone.c @@ -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); } -- 2.50.1