# HG changeset patch # User Timo Sirainen # Date 1214543454 -10800 # Node ID 439636cce455ccdabcead22549f5340d0c82f8f1 # Parent 83019368c9dcd82394aa57bf00c589b568de73f3 Memory leak fixes. 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 @@ return ret < 0; ctx = imap_fetch_init(cmd, client->mailbox); - if (ctx == NULL) + 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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);