From: Vsevolod Stakhov Date: Wed, 18 Jan 2017 13:49:00 +0000 (+0000) Subject: [Fix] Plug memory leak in adding radix trees X-Git-Tag: 1.5.0~311 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f62c08386a3df819f50681c7901c5ae2990eaa88;p=thirdparty%2Frspamd.git [Fix] Plug memory leak in adding radix trees --- diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c index 1ed4aff7d0..581c4b85b8 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);