From: Richard Russon Date: Sat, 13 Oct 2018 11:09:00 +0000 (+0100) Subject: fix mailbox crashes X-Git-Tag: 2019-10-25~603 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c9a6d976dbe663761a2d8e4c0654839bb8c1fa3;p=neomutt fix mailbox crashes Fixes #1360 Fixes #1361 Thanks to Sergey Alirzaev (@l29ah) --- diff --git a/curs_main.c b/curs_main.c index 8f9f45bf8..03c746820 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1854,8 +1854,11 @@ int mutt_index_menu(void) /* do a sanity check even if mx_mbox_sync failed. */ - if (menu->current < 0 || menu->current >= Context->mailbox->vcount) + if ((menu->current < 0) || (Context && Context->mailbox && + (menu->current >= Context->mailbox->vcount))) + { menu->current = ci_first_message(); + } } /* check for a fatal error, or all messages deleted */ diff --git a/mailbox.c b/mailbox.c index a9bd41942..79988f0e4 100644 --- a/mailbox.c +++ b/mailbox.c @@ -745,9 +745,10 @@ int mutt_mailbox_check(int force) #endif /* check device ID and serial number instead of comparing paths */ - if (!Context || Context->mailbox->magic == MUTT_IMAP || Context->mailbox->magic == MUTT_POP + if (!Context || !Context->mailbox || (Context->mailbox->magic == MUTT_IMAP) || + (Context->mailbox->magic == MUTT_POP) #ifdef USE_NNTP - || Context->mailbox->magic == MUTT_NNTP + || (Context->mailbox->magic == MUTT_NNTP) #endif || stat(Context->mailbox->path, &contex_sb) != 0) {