]> granicus.if.org Git - neomutt/commitdiff
fix mailbox crashes
authorRichard Russon <rich@flatcap.org>
Sat, 13 Oct 2018 11:09:00 +0000 (12:09 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 13 Oct 2018 11:09:01 +0000 (12:09 +0100)
Fixes #1360
Fixes #1361

Thanks to Sergey Alirzaev (@l29ah)

curs_main.c
mailbox.c

index 8f9f45bf83b2ead8e128a3038729370deb3ec68c..03c74682096bc4192fbceb6beb9d8ab9818bc345 100644 (file)
@@ -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 */
index a9bd41942e2529291961b65587692e7d91f0d432..79988f0e4ad45fef82cad03cd31375197ab34cb4 100644 (file)
--- 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)
   {