]> source.dussan.org Git - rspamd.git/commitdiff
Fix several memory leaks in rspamd.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 24 Feb 2011 16:45:30 +0000 (19:45 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 24 Feb 2011 16:45:30 +0000 (19:45 +0300)
src/controller.c
src/dns.c
src/message.c
src/plugins/regexp.c
src/worker.c

index 162217828b88e9c37d7b044cb60d22b657fbb98e..380c477910f44933140e313d92e589ff78fa27d4 100644 (file)
@@ -1019,7 +1019,7 @@ controller_err_socket (GError * err, void *arg)
        if (err->code != EOF) {
                msg_info ("abnormally closing control connection, error: %s", err->message);
        }
-
+       g_error_free (err);
        /* Free buffers */
        destroy_session (session->s);
 }
index a870012608c0681eb0a4459171b1101cc655abc4..e11d035820b2e7bd2c69ee41c37ed62a1b1de887 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -955,6 +955,9 @@ dns_parse_reply (guint8 *in, gint r, struct rspamd_dns_resolver *resolver, struc
                        rep->elements = g_list_prepend (rep->elements, elt);
                }
        }
+       if (rep->elements) {
+               memory_pool_add_destructor (req->pool, (pool_destruct_func)g_list_free, rep->elements);
+       }
        
        return rep;
 }
index a7b4d625eedf3fcbd92c64ee689792e90cacb243..0a88ab0f7a6c5740c589e475471fa7a8bd5082ca 100644 (file)
@@ -1015,8 +1015,8 @@ process_message (struct worker_task *task)
 
                if (task->raw_headers) {
                        memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_free, task->raw_headers);
-                       memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_list_free, task->raw_headers_list);
                        process_raw_headers (task);
+                       memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_list_free, task->raw_headers_list);
                }
 
                task->rcpts = g_mime_message_get_all_recipients (message);
index d6e79f07d42e8063f1d8bc73e6c6a7535a08a151..8afefb9da975424e9107a465a6f619467d1ad579 100644 (file)
@@ -674,6 +674,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar
                        return 0;
                }
                else {
+                       memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_list_free, headerlist);
                        /* Check whether we have regexp for it */
                        if (re->regexp == NULL) {
                                debug_task ("regexp contains only header and it is found %s", re->header);
@@ -684,7 +685,6 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar
                        cur = headerlist;
                        while (cur) {
                                debug_task ("found header \"%s\" with value \"%s\"", re->header, (const gchar *)cur->data);
-
                                /* Try to match regexp */
                                if (cur->data && g_regex_match_full (re->regexp, cur->data, -1, 0, 0, NULL, &err) == TRUE) {
                                        if (G_UNLIKELY (re->is_test)) {
index 0ac952b799e0b8b1aecefb980ea14926179cf3e4..738002209b839fdccba813d727479750d7454621 100644 (file)
@@ -267,6 +267,9 @@ free_task (struct worker_task *task, gboolean is_soft)
                if (task->messages) {
                        g_list_free (task->messages);
                }
+               if (task->received) {
+                       g_list_free (task->received);
+               }
                memory_pool_delete (task->task_pool);
                if (task->dispatcher) {
                        if (is_soft) {
@@ -449,6 +452,7 @@ err_socket (GError * err, void *arg)
        if (ctx->is_custom) {
                fin_custom_filters (task);
        }
+       g_error_free (err);
        if (task->state != WRITE_REPLY) {
                destroy_session (task->s);
        }