summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-10-02 16:53:04 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-10-02 16:53:04 +0400
commite6a1d22de250c10992b484635fd95a03f197f779 (patch)
tree8880907edbd20d3fd974af4fcf25960ad18d73a5 /src
parent032b6404155a362d7d5172dd7f1e3688dda6bf25 (diff)
downloadrspamd-e6a1d22de250c10992b484635fd95a03f197f779.tar.gz
rspamd-e6a1d22de250c10992b484635fd95a03f197f779.zip
* Fix some memory issues with lua (strings that are returned from lua can be freed early)
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_config.c2
-rw-r--r--src/lua/lua_task.c4
-rw-r--r--src/plugins/lua/received_rbl.lua6
-rw-r--r--src/plugins/regexp.c2
-rw-r--r--src/plugins/surbl.c1
5 files changed, 9 insertions, 6 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index edd2bc6ea..f62f45bef 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -174,7 +174,7 @@ lua_metric_register_symbol (lua_State *L)
struct lua_callback_data *cd;
if (metric) {
- name = luaL_checkstring (L, 2);
+ name = g_strdup (luaL_checkstring (L, 2));
weight = luaL_checknumber (L, 3);
callback = luaL_checkstring (L, 4);
if (name) {
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 594c7ef5c..71e7f6224 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -111,8 +111,8 @@ lua_task_insert_result (lua_State *L)
int i, top;
if (task != NULL) {
- metric_name = luaL_checkstring (L, 2);
- symbol_name = luaL_checkstring (L, 3);
+ metric_name = memory_pool_strdup (task->task_pool, luaL_checkstring (L, 2));
+ symbol_name = memory_pool_strdup (task->task_pool, luaL_checkstring (L, 3));
flag = luaL_checknumber (L, 4);
top = lua_gettop (L);
/* Get additional options */
diff --git a/src/plugins/lua/received_rbl.lua b/src/plugins/lua/received_rbl.lua
index bee027f50..fa29cabc8 100644
--- a/src/plugins/lua/received_rbl.lua
+++ b/src/plugins/lua/received_rbl.lua
@@ -8,9 +8,9 @@
-- };
-metric = 'default'
-symbol = 'RECEIVED_RBL'
-rbls = {}
+local metric = 'default'
+local symbol = 'RECEIVED_RBL'
+local rbls = {}
function dns_cb(task, to_resolve, results, err)
if results then
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index d8d9f3ea8..ec07bc0ad 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -544,6 +544,7 @@ process_regexp_expression (struct expression *expr, char *symbol, struct worker_
re = parse_regexp (task->cfg->cfg_pool, it->content.operand, task->cfg->raw_mode);
if (re == NULL) {
msg_warn ("process_regexp_expression: cannot parse regexp, skip expression");
+ g_queue_free (stack);
return FALSE;
}
it->content.operand = re;
@@ -586,6 +587,7 @@ process_regexp_expression (struct expression *expr, char *symbol, struct worker_
if (!g_queue_is_empty (stack)) {
op1 = GPOINTER_TO_SIZE (g_queue_pop_head (stack));
if (op1) {
+ g_queue_free (stack);
return TRUE;
}
}
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 75d0f0f3b..61f70586e 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -346,6 +346,7 @@ format_surbl_request (memory_pool_t *pool, f_str_t *hostname, struct suffix_item
g_match_info_free (info);
return result;
}
+ g_match_info_free (info);
}
/* Try to match normal domain */
if (g_regex_match_full (surbl_module_ctx->extract_normal_regexp, hostname->begin, hostname->len, 0, 0, &info, NULL) == TRUE) {