From: Timo Sirainen Date: Wed, 5 Oct 2016 13:34:16 +0000 (+0300) Subject: lib-storage: Fixed assert-crash in mailbox_save_cancel() X-Git-Tag: 2.2.26~177 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=367aa5edb05b8debad532cce636cce8048eaf8e1;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fixed assert-crash in mailbox_save_cancel() Broken by 05150df8f. Fixes: Panic: file mail-storage.c: line 2137 (mailbox_save_context_reset): assertion failed: (ctx->saving) --- diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 7bbda4ddc9..20925a0207 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -2128,13 +2128,16 @@ mailbox_save_add_pvt_flags(struct mailbox_transaction_context *t, save->flags = pvt_flags; } -static void mailbox_save_context_reset(struct mail_save_context *ctx) +static void +mailbox_save_context_reset(struct mail_save_context *ctx, bool success) { i_assert(!ctx->unfinished); if (!ctx->copying_or_moving) { - /* we're finishing a save (not copy/move) */ + /* we're finishing a save (not copy/move). Note that we could + have come here also from mailbox_save_cancel(), in which + case ctx->saving may be FALSE. */ i_assert(!ctx->copying_via_save); - i_assert(ctx->saving); + i_assert(ctx->saving || !success); ctx->saving = FALSE; } else { i_assert(ctx->copying_via_save); @@ -2178,7 +2181,7 @@ int mailbox_save_finish(struct mail_save_context **_ctx) } if (keywords != NULL) mailbox_keywords_unref(&keywords); - mailbox_save_context_reset(ctx); + mailbox_save_context_reset(ctx, TRUE); return ret; } @@ -2201,7 +2204,7 @@ void mailbox_save_cancel(struct mail_save_context **_ctx) mail = (struct mail_private *)ctx->dest_mail; mail->v.close(&mail->mail); } - mailbox_save_context_reset(ctx); + mailbox_save_context_reset(ctx, FALSE); } struct mailbox_transaction_context *