]> granicus.if.org Git - neomutt/commitdiff
fix: stop CUR_EMAIL underflow in entire-thread
authorAustin Ray <austin@austinray.io>
Wed, 22 May 2019 20:40:03 +0000 (16:40 -0400)
committerRichard Russon <rich@flatcap.org>
Fri, 24 May 2019 09:37:53 +0000 (10:37 +0100)
entire-thread will underflow CUR_EMAIL macro if no mailbox is
configured. To prevent this, call 'prereq()' before any other logic.
'prereq()' will ensure we have a mailbox thus preventing the underflow.

flatcap deserves credit for identifying the solution.

Fixes: #1719
index.c

diff --git a/index.c b/index.c
index f55fc5d625ae6a56cb985ce7b85ecc778b6380d6..bb1cbe1f2fdb69386db4a54b873169a8c72d89c6 100644 (file)
--- a/index.c
+++ b/index.c
@@ -1959,6 +1959,8 @@ int mutt_index_menu(void)
 #ifdef USE_NOTMUCH
       case OP_MAIN_ENTIRE_THREAD:
       {
+        if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_VISIBLE))
+          break;
         if (!Context || (Context->mailbox->magic != MUTT_NOTMUCH))
         {
           if (!CUR_EMAIL || !CUR_EMAIL->env || !CUR_EMAIL->env->message_id)
@@ -1981,8 +1983,6 @@ int mutt_index_menu(void)
           else
             main_change_folder(menu, op, NULL, buf, sizeof(buf), &oldcount, &index_hint);
         }
-        if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_VISIBLE))
-          break;
         oldcount = Context->mailbox->msg_count;
         struct Email *oldcur = CUR_EMAIL;
         if (nm_read_entire_thread(Context->mailbox, CUR_EMAIL) < 0)