From: Timo Sirainen Date: Sun, 28 Feb 2010 13:29:59 +0000 (+0200) Subject: Memory leak fixes. X-Git-Tag: 2.0.beta4~154 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=878a83a906e1be6354b563ead096955a22ad5fbe;p=thirdparty%2Fdovecot%2Fcore.git Memory leak fixes. --HG-- branch : HEAD --- diff --git a/src/lib-master/master-service-settings-cache.c b/src/lib-master/master-service-settings-cache.c index e4a946043c..805bacdec3 100644 --- a/src/lib-master/master-service-settings-cache.c +++ b/src/lib-master/master-service-settings-cache.c @@ -74,18 +74,23 @@ void master_service_settings_cache_deinit(struct master_service_settings_cache * struct master_service_settings_cache *cache = *_cache; struct settings_entry *entry, *next; + /* parsers need to be deinitialized, because they reference the pool */ for (entry = cache->oldest_global; entry != NULL; entry = next) { next = entry->next; + settings_parser_deinit(&entry->parser); pool_unref(&entry->pool); } for (entry = cache->oldest; entry != NULL; entry = next) { next = entry->next; + settings_parser_deinit(&entry->parser); pool_unref(&entry->pool); } if (cache->local_host_hash != NULL) hash_table_destroy(&cache->local_host_hash); if (cache->local_ip_hash != NULL) hash_table_destroy(&cache->local_ip_hash); + if (cache->global_parser != NULL) + settings_parser_deinit(&cache->global_parser); pool_unref(&cache->pool); } @@ -148,7 +153,6 @@ static void setting_entry_detach(struct master_service_settings_cache *cache, struct settings_entry *entry) { - DLLIST2_REMOVE(&cache->oldest, &cache->newest, entry); cache->cache_malloc_size -= pool_alloconly_get_total_alloc_size(entry->pool); @@ -157,6 +161,7 @@ setting_entry_detach(struct master_service_settings_cache *cache, hash_table_remove(cache->local_host_hash, entry->local_host); if (entry->local_ip.family != 0) hash_table_remove(cache->local_ip_hash, &entry->local_ip); + settings_parser_deinit(&entry->parser); } static void cache_add(struct master_service_settings_cache *cache, diff --git a/src/lib-storage/mail-storage-service.c b/src/lib-storage/mail-storage-service.c index 87507fd1a8..87cf1230ed 100644 --- a/src/lib-storage/mail-storage-service.c +++ b/src/lib-storage/mail-storage-service.c @@ -498,7 +498,8 @@ mail_storage_service_init(struct master_service *service, count = 0; else for (count = 0; set_roots[count] != NULL; count++) ; - ctx->set_roots = i_new(const struct setting_parser_info *, count + 2); + ctx->set_roots = + p_new(pool, const struct setting_parser_info *, count + 2); ctx->set_roots[0] = &mail_user_setting_parser_info; memcpy(ctx->set_roots + 1, set_roots, sizeof(*ctx->set_roots) * count);