From b35299b4e3a6cf75cfa19783dda35411508d2913 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 5 Feb 2016 12:42:43 +0000 Subject: Fix leaks in lua error paths --- src/libserver/cfg_rcl.c | 2 +- src/libserver/cfg_utils.c | 2 ++ src/libserver/symbols_cache.c | 1 + src/libserver/task.c | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/libserver') diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index df9768792..ffc6f9086 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -772,7 +772,7 @@ rspamd_rcl_lua_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, lua_src, tb->str); g_string_free (tb, TRUE); - lua_pop (L, 1); + lua_pop (L, 2); if (chdir (cur_dir) == -1) { msg_err_config ("cannot chdir to %s: %s", cur_dir, diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 6ecd7b429..66a67fe13 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -379,6 +379,8 @@ rspamd_config_process_var (struct rspamd_config *cfg, const rspamd_ftok_t *var, if (lua_pcall (cfg->lua_state, 0, 1, 0) != 0) { msg_err_config ("error executing lua code: '%T': %s", content, lua_tostring (cfg->lua_state, -1)); + lua_pop (cfg->lua_state, 1); + return FALSE; } diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c index 53c065dfd..50012c1a9 100644 --- a/src/libserver/symbols_cache.c +++ b/src/libserver/symbols_cache.c @@ -1048,6 +1048,7 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task, if (lua_pcall (L, 1, 1, 0) != 0) { msg_info_task ("call to condition for %s failed: %s", item->symbol, lua_tostring (L, -1)); + lua_pop (L, 1); } else { check = lua_toboolean (L, -1); diff --git a/src/libserver/task.c b/src/libserver/task.c index 4194ac94c..1220dc4bc 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -1076,6 +1076,7 @@ rspamd_task_write_log (struct rspamd_task *task) if (lua_pcall (L, 1, 1, 0) != 0) { msg_err_task ("call to log function failed: %s", lua_tostring (L, -1)); + lua_pop (L, 1); } else { lua_str = lua_tolstring (L, -1, &lua_str_len); -- cgit v1.2.3