From 42eafa118322a9b432068c05245281fea974cbea Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Fri, 12 May 2017 09:15:00 -0700 Subject: [PATCH] Turn IMAP_EXPUNGE_EXPECTED back off when syncing. (closes #3940). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit imap_sync_mailbox() turned on IMAP_EXPUNGE_EXPECTED when issuing a EXPUNGE command during a sync. However, it forgot to turn it back off. That meant that an unexpected EXPUNGE that occurred during a mx_check_mailbox -> imap_check_mailbox() -> imap_cmd_finish() call was not setting idata->check_status = IMAP_EXPUNGE_PENDING; and so imap_check_mailbox() was not returning MUTT_REOPENED. This meant that although the Context had been changed, the index did not run update_index(), resulting in a possible segfault. Thanks to Uroš Juvan for reporting the issue, and his invaluable description of how to reproduce the problem. --- imap/imap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imap/imap.c b/imap/imap.c index 975de38d5..997896c97 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1338,10 +1338,12 @@ int imap_sync_mailbox(struct Context *ctx, int expunge) idata->reopen |= IMAP_EXPUNGE_EXPECTED; if (imap_exec(idata, "EXPUNGE", 0) != 0) { + idata->reopen &= ~IMAP_EXPUNGE_EXPECTED; imap_error(_("imap_sync_mailbox: EXPUNGE failed"), idata->buf); rc = -1; goto out; } + idata->reopen &= ~IMAP_EXPUNGE_EXPECTED; } if (expunge && ctx->closing) -- 2.40.0