Fixes #1360
Fixes #1361
Thanks to Sergey Alirzaev (@l29ah)
/* 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 */
#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)
{