]> source.dussan.org Git - rspamd.git/commitdiff
* Fix some memory issues with lua (strings that are returned from lua can be freed...
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 2 Oct 2009 12:53:04 +0000 (16:53 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 2 Oct 2009 12:53:04 +0000 (16:53 +0400)
src/lua/lua_config.c
src/lua/lua_task.c
src/plugins/lua/received_rbl.lua
src/plugins/regexp.c
src/plugins/surbl.c

index edd2bc6eafc5b7e0efedea7e3706561934b312a7..f62f45bef551d78551c2fb5da41f143343d6cfed 100644 (file)
@@ -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) {
index 594c7ef5c3c31ceb5889d0fa182662c06ccef751..71e7f62242998c43c0d8cbed766575fe0121367a 100644 (file)
@@ -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 */
index bee027f50af5f9af80d434c35430cb644e48ce24..fa29cabc8059d4a1dcb1b62441dfe264f3dc98fe 100644 (file)
@@ -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
index d8d9f3ea8c34ed1aea73d477c8f4d13f85cc14fe..ec07bc0ad62d5614f2d8683fe032020d106ab9ab 100644 (file)
@@ -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;
                }
        }
index 75d0f0f3bb9c04a15283df8b4c74fbfb15248a6d..61f70586e316fab347e7e40118c5ba2a7952143b 100644 (file)
@@ -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) {