dovecot-1.2: Memory leak fixes.

dovecot at dovecot.org dovecot at dovecot.org
Fri Jun 27 08:11:04 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/439636cce455
changeset: 7956:439636cce455
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 27 08:10:54 2008 +0300
description:
Memory leak fixes.

diffstat:

5 files changed, 17 insertions(+), 6 deletions(-)
src/imap/cmd-fetch.c                      |    6 ++++--
src/imap/imap-fetch.c                     |    1 +
src/lib-index/mail-index-modseq.c         |    4 ++--
src/lib-storage/index/index-sort-string.c |    9 +++++++--
src/lib-storage/index/index-sort.c        |    3 +++

diffs (77 lines):

diff -r 83019368c9dc -r 439636cce455 src/imap/cmd-fetch.c
--- a/src/imap/cmd-fetch.c	Thu Jun 26 21:37:31 2008 +0300
+++ b/src/imap/cmd-fetch.c	Fri Jun 27 08:10:54 2008 +0300
@@ -201,8 +201,10 @@ bool cmd_fetch(struct client_command_con
 		return ret < 0;
 
 	ctx = imap_fetch_init(cmd, client->mailbox);
-	if (ctx == NULL)
-		return TRUE;
+	if (ctx == NULL) {
+		mail_search_args_unref(&search_args);
+		return TRUE;
+	}
 	ctx->search_args = search_args;
 
 	if (!fetch_parse_args(ctx, &args[1]) ||
diff -r 83019368c9dc -r 439636cce455 src/imap/imap-fetch.c
--- a/src/imap/imap-fetch.c	Thu Jun 26 21:37:31 2008 +0300
+++ b/src/imap/imap-fetch.c	Fri Jun 27 08:10:54 2008 +0300
@@ -562,6 +562,7 @@ int imap_fetch_deinit(struct imap_fetch_
 	if (ctx->mail != NULL)
 		mail_free(&ctx->mail);
 
+	mail_search_args_unref(&ctx->search_args);
 	if (ctx->search_ctx != NULL) {
 		if (mailbox_search_deinit(&ctx->search_ctx) < 0)
 			ctx->failed = TRUE;
diff -r 83019368c9dc -r 439636cce455 src/lib-index/mail-index-modseq.c
--- a/src/lib-index/mail-index-modseq.c	Thu Jun 26 21:37:31 2008 +0300
+++ b/src/lib-index/mail-index-modseq.c	Fri Jun 27 08:10:54 2008 +0300
@@ -608,8 +608,8 @@ void mail_index_map_modseq_free(struct m
 
 	metadata = array_get_modifiable(&mmap->metadata_modseqs, &count);
 	for (i = 0; i < count; i++) {
-		if (array_is_created(&metadata->modseqs))
-			array_free(&metadata->modseqs);
+		if (array_is_created(&metadata[i].modseqs))
+			array_free(&metadata[i].modseqs);
 	}
 	array_free(&mmap->metadata_modseqs);
 	i_free(mmap);
diff -r 83019368c9dc -r 439636cce455 src/lib-storage/index/index-sort-string.c
--- a/src/lib-storage/index/index-sort-string.c	Thu Jun 26 21:37:31 2008 +0300
+++ b/src/lib-storage/index/index-sort-string.c	Fri Jun 27 08:10:54 2008 +0300
@@ -753,7 +753,10 @@ void index_sort_list_finish_string(struc
 		qsort(nodes, count, sizeof(struct mail_sort_node),
 		      sort_node_cmp);
 
-		i_array_init(&program->seqs, count);
+		if (!array_is_created(&program->seqs))
+			i_array_init(&program->seqs, count);
+		else
+			array_clear(&program->seqs);
 		for (i = 0; i < count; i++) {
 			seq = nodes[i].seq;
 			array_append(&program->seqs, &seq, 1);
@@ -818,4 +821,6 @@ void index_sort_list_finish_string(struc
 	}
 
 	array_free(&ctx->zero_nodes);
-}
+	i_free(ctx);
+	program->context = NULL;
+}
diff -r 83019368c9dc -r 439636cce455 src/lib-storage/index/index-sort.c
--- a/src/lib-storage/index/index-sort.c	Thu Jun 26 21:37:31 2008 +0300
+++ b/src/lib-storage/index/index-sort.c	Fri Jun 27 08:10:54 2008 +0300
@@ -235,6 +235,9 @@ void index_sort_program_deinit(struct ma
 	struct mail_search_sort_program *program = *_program;
 
 	*_program = NULL;
+
+	if (program->context != NULL)
+		index_sort_list_finish(program);
 	mail_free(&program->temp_mail);
 	array_free(&program->seqs);
 	i_free(program);


More information about the dovecot-cvs mailing list