diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-02 14:56:55 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-02 14:56:55 +0100 |
commit | 26832a9237178a763d57034c9e9636da0d6d8c7b (patch) | |
tree | 8e43990c3f6cdef6389475654b695a3bb8be825c | |
parent | cfc1e965d51ed2fc2c6462e979094e47e47ba2f4 (diff) | |
download | rspamd-26832a9237178a763d57034c9e9636da0d6d8c7b.tar.gz rspamd-26832a9237178a763d57034c9e9636da0d6d8c7b.zip |
Memory leak.
-rw-r--r-- | src/libstat/stat_process.c | 3 | ||||
-rw-r--r-- | src/libutil/util.c | 8 | ||||
-rw-r--r-- | src/libutil/util.h | 6 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 7587baec1..7549bcce3 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -95,7 +95,8 @@ preprocess_init_stat_token (gpointer k, gpointer v, gpointer d) t->results = g_array_sized_new (FALSE, TRUE, sizeof (struct rspamd_token_result), cbdata->results_count); - g_array_set_size (t->results, cbdata->results_count); + rspamd_mempool_add_destructor (cbdata->task->task_pool, + rspamd_array_free_hard, t->results); cur = g_list_first (cbdata->classifier_runtimes); diff --git a/src/libutil/util.c b/src/libutil/util.c index 259e242e3..5e48dcdcf 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -2340,3 +2340,11 @@ rspamd_ptr_array_free_hard (gpointer p) g_ptr_array_free (ar, TRUE); } + +void +rspamd_array_free_hard (gpointer p) +{ + GArray *ar = (GArray *)p; + + g_array_free (ar, TRUE); +} diff --git a/src/libutil/util.h b/src/libutil/util.h index b0825bfbf..de28fe93b 100644 --- a/src/libutil/util.h +++ b/src/libutil/util.h @@ -447,4 +447,10 @@ gdouble rspamd_get_ticks (void); */ void rspamd_ptr_array_free_hard (gpointer p); +/** + * Special utility to help array freeing in rspamd_mempool + * @param p + */ +void rspamd_array_free_hard (gpointer p); + #endif |