From 7c9a6d976dbe663761a2d8e4c0654839bb8c1fa3 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 13 Oct 2018 12:09:00 +0100 Subject: [PATCH] fix mailbox crashes Fixes #1360 Fixes #1361 Thanks to Sergey Alirzaev (@l29ah) --- curs_main.c | 5 ++++- mailbox.c | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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) { -- 2.40.0