# HG changeset patch # User Timo Sirainen # Date 1493379336 -10800 # Node ID b57e0cfd334d8831a29c4d465612da12707fe4ea # Parent ce5fc3bd3b40211a5c7c27f597b39f898c311af1 lib-storage: When save is aborted, close dest_mail without crashing 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. diff -r ce5fc3bd3b40 -r b57e0cfd334d src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Fri Apr 28 14:06:43 2017 +0300 +++ b/src/lib-storage/index/index-storage.c Fri Apr 28 14:35:36 2017 +0300 @@ -1117,6 +1117,13 @@ 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. */