]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: When save is aborted, close dest_mail without crashing
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 28 Apr 2017 11:35:36 +0000 (14:35 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 28 Apr 2017 11:35:36 +0000 (14:35 +0300)
Fixes:
Panic: file mail-index-transaction-update.c: line 1023 (mail_index_update_ext): assertion failed: (seq > 0 && (seq <= mail_index_view_get_messages_count(t->view) || seq <= t->last_new_seq))

Because cache was still attempted to be updated, but the mail was already
expunged from index.

src/lib-storage/index/index-storage.c

index 8f9189a74e6904366457e4552e795e9b927cb173..c0d241707ea657e5c1893a3165dae89252334282 100644 (file)
@@ -1118,6 +1118,13 @@ int index_storage_save_continue(struct mail_save_context *ctx,
 
 void index_storage_save_abort_last(struct mail_save_context *ctx, uint32_t seq)
 {
+       struct index_mail *imail = (struct index_mail *)ctx->dest_mail;
+
+       /* Close the mail before it's expunged. This allows it to be
+          reset cleanly. */
+       imail->data.no_caching = TRUE;
+       imail->mail.v.close(&imail->mail.mail);
+
        mail_index_expunge(ctx->transaction->itrans, seq);
        /* currently we can't just drop pending cache updates for this one
           specific record, so we'll reset the whole cache transaction. */