dovecot-2.0: lib-storage: Don't assert-crash when copying a mail...

dovecot at dovecot.org dovecot at dovecot.org
Wed May 26 19:22:29 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/0918cb06c906
changeset: 11381:0918cb06c906
user:      Timo Sirainen <tss at iki.fi>
date:      Wed May 26 17:22:26 2010 +0100
description:
lib-storage: Don't assert-crash when copying a mail fails.

diffstat:

 src/lib-storage/mail-copy.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (35 lines):

diff -r 7cbc5854fbeb -r 0918cb06c906 src/lib-storage/mail-copy.c
--- a/src/lib-storage/mail-copy.c	Wed May 26 17:09:22 2010 +0100
+++ b/src/lib-storage/mail-copy.c	Wed May 26 17:22:26 2010 +0100
@@ -6,8 +6,9 @@
 #include "mail-copy.h"
 
 static int
-mail_storage_try_copy(struct mail_save_context *ctx, struct mail *mail)
+mail_storage_try_copy(struct mail_save_context **_ctx, struct mail *mail)
 {
+	struct mail_save_context *ctx = *_ctx;
 	struct mail_private *pmail = (struct mail_private *)mail;
 	struct istream *input;
 	const char *from_envelope, *guid;
@@ -41,7 +42,7 @@
 			mailbox_save_set_guid(ctx, guid);
 	}
 
-	if (mailbox_save_begin(&ctx, input) < 0)
+	if (mailbox_save_begin(_ctx, input) < 0)
 		return -1;
 
 	do {
@@ -66,8 +67,9 @@
 		mailbox_keywords_ref(ctx->transaction->box, ctx->keywords);
 	}
 
-	if (mail_storage_try_copy(ctx, mail) < 0) {
-		mailbox_save_cancel(&ctx);
+	if (mail_storage_try_copy(&ctx, mail) < 0) {
+		if (ctx != NULL)
+			mailbox_save_cancel(&ctx);
 		return -1;
 	}
 	return mailbox_save_finish(&ctx);


More information about the dovecot-cvs mailing list