aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/fuzzy_check.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-17 16:53:20 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-17 16:53:20 +0000
commit6ff5a8debb423d1c7b62f18833cdd500876848af (patch)
tree25e76b93869c9c844aacda9c7ba34e0f8eab299d /src/plugins/fuzzy_check.c
parent5dd52de750ce5dfbbe182d204d0a66498bc69a9a (diff)
downloadrspamd-6ff5a8debb423d1c7b62f18833cdd500876848af.tar.gz
rspamd-6ff5a8debb423d1c7b62f18833cdd500876848af.zip
[Fix] Fix memory leak on reload in plugins
Diffstat (limited to 'src/plugins/fuzzy_check.c')
-rw-r--r--src/plugins/fuzzy_check.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 26ad295fa..e6a7b1bc1 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -637,13 +637,16 @@ fuzzy_check_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
lua_State *L = cfg->lua_state;
- fuzzy_module_ctx = g_malloc0 (sizeof (struct fuzzy_ctx));
+ if (fuzzy_module_ctx == NULL) {
+ fuzzy_module_ctx = g_malloc0 (sizeof (struct fuzzy_ctx));
+
+ fuzzy_module_ctx->fuzzy_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL);
+ /* TODO: this should match rules count actually */
+ fuzzy_module_ctx->keypairs_cache = rspamd_keypair_cache_new (32);
+ fuzzy_module_ctx->fuzzy_rules = g_ptr_array_new ();
+ }
- fuzzy_module_ctx->fuzzy_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL);
fuzzy_module_ctx->cfg = cfg;
- /* TODO: this should match rules count actually */
- fuzzy_module_ctx->keypairs_cache = rspamd_keypair_cache_new (32);
- fuzzy_module_ctx->fuzzy_rules = g_ptr_array_new ();
*ctx = (struct module_ctx *)fuzzy_module_ctx;
@@ -1043,10 +1046,12 @@ fuzzy_check_module_reconfig (struct rspamd_config *cfg)
saved_ctx = fuzzy_module_ctx->ctx;
rspamd_mempool_delete (fuzzy_module_ctx->fuzzy_pool);
rspamd_keypair_cache_destroy (fuzzy_module_ctx->keypairs_cache);
+ g_ptr_array_free (fuzzy_module_ctx->fuzzy_rules, TRUE);
memset (fuzzy_module_ctx, 0, sizeof (*fuzzy_module_ctx));
fuzzy_module_ctx->ctx = saved_ctx;
fuzzy_module_ctx->fuzzy_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL);
fuzzy_module_ctx->cfg = cfg;
+ fuzzy_module_ctx->fuzzy_rules = g_ptr_array_new ();
fuzzy_module_ctx->keypairs_cache = rspamd_keypair_cache_new (32);
return fuzzy_check_module_config (cfg);