diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-18 13:49:00 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-18 13:49:00 +0000 |
commit | f62c08386a3df819f50681c7901c5ae2990eaa88 (patch) | |
tree | 52f1d2401bb88f5c5dd4413ece4e4123abc82487 /src/lua/lua_map.c | |
parent | 3a3a6f161bd5dd6c3452d103b7ac5e3b7a0932e6 (diff) | |
download | rspamd-f62c08386a3df819f50681c7901c5ae2990eaa88.tar.gz rspamd-f62c08386a3df819f50681c7901c5ae2990eaa88.zip |
[Fix] Plug memory leak in adding radix trees
Diffstat (limited to 'src/lua/lua_map.c')
-rw-r--r-- | src/lua/lua_map.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c index 1ed4aff7d..581c4b85b 100644 --- a/src/lua/lua_map.c +++ b/src/lua/lua_map.c @@ -171,12 +171,11 @@ lua_config_radix_from_config (lua_State *L) obj = rspamd_config_get_module_opt (cfg, mname, optname); if (obj) { map = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (*map)); - map->data.radix = radix_create_compressed (); map->type = RSPAMD_LUA_MAP_RADIX; - map->data.radix = radix_create_compressed (); map->flags |= RSPAMD_LUA_MAP_FLAG_EMBEDDED; if (ucl_object_type (obj) == UCL_STRING) { + map->data.radix = radix_create_compressed (); radix_add_generic_iplist (ucl_obj_tostring (obj), &map->data.radix, TRUE); } @@ -194,6 +193,9 @@ lua_config_radix_from_config (lua_State *L) } } + rspamd_mempool_add_destructor (cfg->cfg_pool, + (rspamd_mempool_destruct_t)radix_destroy_compressed, + map->data.radix); pmap = lua_newuserdata (L, sizeof (void *)); *pmap = map; rspamd_lua_setclass (L, "rspamd{map}", -1); |