changeset 6979:1029b2ffad2d HEAD

Fixed memory leak when FETCH command used multiple streams.
author Timo Sirainen <tss@iki.fi>
date Sun, 09 Dec 2007 16:07:58 +0200
parents 4fb1b0f43d60
children d373913cd763
files src/imap/imap-fetch.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-fetch.c	Sun Dec 09 15:50:24 2007 +0200
+++ b/src/imap/imap-fetch.c	Sun Dec 09 16:07:58 2007 +0200
@@ -261,6 +261,8 @@
 		ctx->cont_handler = NULL;
 		ctx->cur_offset = 0;
                 ctx->cur_handler++;
+		if (ctx->cur_input != NULL)
+			i_stream_unref(&ctx->cur_input);
 	}
 
 	/* assume initially that we're locking it */
@@ -286,9 +288,6 @@
 			if (ctx->cmd->cancel)
 				return 1;
 
-			if (ctx->cur_input != NULL)
-				i_stream_unref(&ctx->cur_input);
-
 			if (mailbox_search_next(ctx->search_ctx,
 						ctx->mail) <= 0)
 				break;
@@ -341,6 +340,8 @@
 
 			ctx->cont_handler = NULL;
 			ctx->cur_offset = 0;
+			if (ctx->cur_input != NULL)
+				i_stream_unref(&ctx->cur_input);
 		}
 
 		if (str_len(ctx->cur_str) > 0) {