]> granicus.if.org Git - neomutt/commitdiff
Fix segfault when checking a mailbox after a disconnect
authorPietro Cerutti <gahr@gahr.ch>
Fri, 21 Sep 2018 12:07:19 +0000 (12:07 +0000)
committerPietro Cerutti <gahr@gahr.ch>
Fri, 21 Sep 2018 12:07:19 +0000 (12:07 +0000)
imap/imap.c
imap/util.c

index 798dbc91e73f47e2c12f08cb19c8a8baeaf706e7..48dd50fe20d9d3a53c52e61c5c059f6152bf0de4 100644 (file)
@@ -2508,6 +2508,8 @@ static int imap_mbox_check(struct Context *ctx, int *index_hint)
 
   imap_allow_reopen(ctx);
   rc = imap_check(ctx->mailbox->data, false);
+  /* NOTE - ctx might have been changed at this point. In particular,
+   * ctx->mailbox could be NULL. Beware. */
   imap_disallow_reopen(ctx);
 
   return rc;
index 2085feb3ad6228a1ec252409ccdd1f7f00bbeead..71be50fc77751755b8af627ba4b1939fecf72300 100644 (file)
@@ -1123,7 +1123,7 @@ void imap_allow_reopen(struct Context *ctx)
 void imap_disallow_reopen(struct Context *ctx)
 {
   struct ImapMboxData *mdata = NULL;
-  if (!ctx || !ctx->mailbox->data || ctx->mailbox->magic != MUTT_IMAP)
+  if (!ctx || !ctx->mailbox || !ctx->mailbox->data || ctx->mailbox->magic != MUTT_IMAP)
     return;
 
   mdata = ctx->mailbox->data;