dovecot-2.2: imap: Fixed memory leak on APPEND error conditions.

dovecot at dovecot.org dovecot at dovecot.org
Wed Aug 7 19:47:28 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/5dbea45eecb8
changeset: 16682:5dbea45eecb8
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 07 19:47:17 2013 +0300
description:
imap: Fixed memory leak on APPEND error conditions.

diffstat:

 src/imap/cmd-append.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (43 lines):

diff -r 044ec0204873 -r 5dbea45eecb8 src/imap/cmd-append.c
--- a/src/imap/cmd-append.c	Wed Aug 07 19:40:16 2013 +0300
+++ b/src/imap/cmd-append.c	Wed Aug 07 19:47:17 2013 +0300
@@ -539,6 +539,8 @@
 	} else if (!imap_parse_datetime(internal_date_str,
 					&internal_date, &timezone_offset)) {
 		client_send_command_error(cmd, "Invalid internal date.");
+		if (keywords != NULL)
+			mailbox_keywords_unref(&keywords);
 		return -1;
 	}
 
@@ -560,8 +562,11 @@
 					"NO Can't save a zero byte message.");
 				ctx->failed = TRUE;
 			}
-			if (!*nonsync_r)
+			if (!*nonsync_r) {
+				if (keywords != NULL)
+					mailbox_keywords_unref(&keywords);
 				return -1;
+			}
 			/* {0+} used. although there isn't any point in using
 			   MULTIAPPEND here and adding more messages, it is
 			   technically valid so we'll continue parsing.. */
@@ -580,8 +585,6 @@
 		/* save the mail */
 		ctx->save_ctx = mailbox_save_alloc(ctx->t);
 		mailbox_save_set_flags(ctx->save_ctx, flags, keywords);
-		if (keywords != NULL)
-			mailbox_keywords_unref(&keywords);
 		mailbox_save_set_received_date(ctx->save_ctx,
 					       internal_date, timezone_offset);
 		if (mailbox_save_begin(&ctx->save_ctx, ctx->input) < 0) {
@@ -590,6 +593,8 @@
 			ctx->failed = TRUE;
 		}
 	}
+	if (keywords != NULL)
+		mailbox_keywords_unref(&keywords);
 	ctx->count++;
 
 	if (cat_list == NULL) {


More information about the dovecot-cvs mailing list