From: Timo Sirainen Date: Wed, 17 Jan 2018 13:05:38 +0000 (+0200) Subject: imapc: Fix leaking mail_index_view on delayed expunge handling X-Git-Tag: 2.2.34~132 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3f34e2b4d4646b38d37148d3af5e79ecebbc9b2c;p=thirdparty%2Fdovecot%2Fcore.git imapc: Fix leaking mail_index_view on delayed expunge handling Fixes: Panic: Leaked view for index (in-memory index): Opened in imapc-mailbox.c:47 --- diff --git a/src/lib-storage/index/imapc/imapc-mailbox.c b/src/lib-storage/index/imapc/imapc-mailbox.c index 90dab90af0..a07b27db88 100644 --- a/src/lib-storage/index/imapc/imapc-mailbox.c +++ b/src/lib-storage/index/imapc/imapc-mailbox.c @@ -110,15 +110,22 @@ int imapc_mailbox_commit_delayed_trans(struct imapc_mailbox *mbox, mbox->delayed_sync_cache_trans = NULL; if (mbox->delayed_sync_cache_view != NULL) mail_cache_view_close(&mbox->delayed_sync_cache_view); - if (mbox->sync_view != NULL) - mail_index_view_close(&mbox->sync_view); if (array_count(&mbox->delayed_expunged_uids) > 0) { /* delayed expunges - commit them now in a separate - transaction */ + transaction. Reopen mbox->sync_view to see changes + committed in delayed_sync_trans. */ + if (mbox->sync_view != NULL) + mail_index_view_close(&mbox->sync_view); if (imapc_mailbox_commit_delayed_expunges(mbox) < 0) ret = -1; } + + if (mbox->sync_view != NULL) + mail_index_view_close(&mbox->sync_view); + i_assert(mbox->delayed_sync_trans == NULL); + i_assert(mbox->delayed_sync_view == NULL); + i_assert(mbox->delayed_sync_cache_trans == NULL); return ret; } diff --git a/src/lib-storage/index/imapc/imapc-sync.c b/src/lib-storage/index/imapc/imapc-sync.c index f8e9b25bc1..b3f49c49d4 100644 --- a/src/lib-storage/index/imapc/imapc-sync.c +++ b/src/lib-storage/index/imapc/imapc-sync.c @@ -563,6 +563,7 @@ imapc_sync_begin(struct imapc_mailbox *mbox, return ret; } + i_assert(mbox->sync_view == NULL); i_assert(mbox->delayed_sync_trans == NULL); mbox->sync_view = ctx->sync_view; mbox->delayed_sync_view =