From: Pietro Cerutti Date: Fri, 21 Sep 2018 12:07:19 +0000 (+0000) Subject: Fix segfault when checking a mailbox after a disconnect X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c37afd9ad2a27c71855c8eff37baff8f4a2f739e;p=neomutt Fix segfault when checking a mailbox after a disconnect --- diff --git a/imap/imap.c b/imap/imap.c index 798dbc91e..48dd50fe2 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -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; diff --git a/imap/util.c b/imap/util.c index 2085feb3a..71be50fc7 100644 --- a/imap/util.c +++ b/imap/util.c @@ -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;