changeset 14931:a7928075f0fd

dbox: Crashfix on some failed save error conditions.
author Timo Sirainen <tss@iki.fi>
date Mon, 04 Mar 2013 15:53:42 +0200
parents 09fcb43c47a4
children 87a9eec10145
files src/lib-storage/index/dbox-common/dbox-save.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-common/dbox-save.c	Mon Mar 04 15:18:08 2013 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-save.c	Mon Mar 04 15:53:42 2013 +0200
@@ -106,10 +106,14 @@
 			ctx->failed = TRUE;
 	}
 	if (ctx->ctx.output != dbox_output) {
-		/* e.g. zlib plugin had changed this */
-		o_stream_ref(dbox_output);
-		o_stream_destroy(&ctx->ctx.output);
-		ctx->ctx.output = dbox_output;
+		if (ctx->ctx.output != NULL) {
+			/* e.g. zlib plugin had changed this */
+			o_stream_ref(dbox_output);
+			o_stream_destroy(&ctx->ctx.output);
+			ctx->ctx.output = dbox_output;
+		} else {
+			i_assert(ctx->failed);
+		}
 	}
 	index_mail_cache_parse_deinit(ctx->ctx.dest_mail,
 				      ctx->ctx.received_date, !ctx->failed);