dovecot-2.2: lib-storage: Assert-crash if mailbox_save_context i...

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 16 13:38:25 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/9847164c6fd7
changeset: 15774:9847164c6fd7
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Feb 16 13:34:13 2013 +0200
description:
lib-storage: Assert-crash if mailbox_save_context isn't properly freed before reusing.

diffstat:

 src/lib-storage/index/index-storage.c  |  1 +
 src/lib-storage/mail-storage-private.h |  3 +++
 src/lib-storage/mail-storage.c         |  2 ++
 3 files changed, 6 insertions(+), 0 deletions(-)

diffs (36 lines):

diff -r 2cf0049a8e75 -r 9847164c6fd7 src/lib-storage/index/index-storage.c
--- a/src/lib-storage/index/index-storage.c	Sat Feb 16 13:32:57 2013 +0200
+++ b/src/lib-storage/index/index-storage.c	Sat Feb 16 13:34:13 2013 +0200
@@ -754,6 +754,7 @@
 	i_free_and_null(ctx->data.pop3_uidl);
 	index_attachment_save_free(ctx);
 	memset(&ctx->data, 0, sizeof(ctx->data));
+	ctx->unfinished = FALSE;
 }
 
 static void
diff -r 2cf0049a8e75 -r 9847164c6fd7 src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h	Sat Feb 16 13:32:57 2013 +0200
+++ b/src/lib-storage/mail-storage-private.h	Sat Feb 16 13:34:13 2013 +0200
@@ -528,6 +528,9 @@
 	bool (*part_is_attachment)(struct mail_save_context *ctx,
 				   const struct mail_attachment_part *part);
 
+	/* mailbox_save_alloc() called, but finish/cancel not.
+	   the same context is usually returned by the backends for reuse. */
+	unsigned int unfinished:1;
 	/* mail was copied using saving */
 	unsigned int copying_via_save:1;
 	/* mail is being saved, not copied */
diff -r 2cf0049a8e75 -r 9847164c6fd7 src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c	Sat Feb 16 13:32:57 2013 +0200
+++ b/src/lib-storage/mail-storage.c	Sat Feb 16 13:34:13 2013 +0200
@@ -1790,6 +1790,8 @@
 	struct mail_save_context *ctx;
 
 	ctx = t->box->v.save_alloc(t);
+	i_assert(!ctx->unfinished);
+	ctx->unfinished = TRUE;
 	ctx->data.received_date = (time_t)-1;
 	ctx->data.save_date = (time_t)-1;
 	return ctx;


More information about the dovecot-cvs mailing list