diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-06 17:48:31 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-06 17:48:31 +0300 |
commit | 555778c43a3148fd88d3b3562ae2634318110b22 (patch) | |
tree | d58ba7b8416540d265ffb93c9e510f3c98f9e495 /src/message.c | |
parent | 4d932e105aef559198ec2f79b43279a18f52db9e (diff) | |
download | rspamd-555778c43a3148fd88d3b3562ae2634318110b22.tar.gz rspamd-555778c43a3148fd88d3b3562ae2634318110b22.zip |
* Remove several memory leaks (found by valgrind)
Diffstat (limited to 'src/message.c')
-rw-r--r-- | src/message.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/message.c b/src/message.c index c2651bdc8..7d30f53f9 100644 --- a/src/message.c +++ b/src/message.c @@ -329,8 +329,12 @@ process_message (struct worker_task *task) GMimeMessage *message; GMimeParser *parser; GMimeStream *stream; - - stream = g_mime_stream_mem_new_with_buffer (task->msg->begin, task->msg->len); + GByteArray *tmp; + + tmp = memory_pool_alloc (task->task_pool, sizeof (GByteArray)); + tmp->data = task->msg->begin; + tmp->len = task->msg->len; + stream = g_mime_stream_mem_new_with_byte_array (tmp); msg_debug ("process_message: construct mime parser from string length %ld", (long int)task->msg->len); /* create a new parser object to parse the stream */ parser = g_mime_parser_new_with_stream (stream); @@ -433,8 +437,13 @@ process_learn (struct controller_session *session) GMimeMessage *message; GMimeParser *parser; GMimeStream *stream; + GByteArray *tmp; + + tmp = memory_pool_alloc (session->session_pool, sizeof (GByteArray)); + tmp->data = session->learn_buf->begin; + tmp->len = session->learn_buf->len; + stream = g_mime_stream_mem_new_with_byte_array (tmp); - stream = g_mime_stream_mem_new_with_buffer (session->learn_buf->begin, session->learn_buf->len); /* create a new parser object to parse the stream */ parser = g_mime_parser_new_with_stream (stream); @@ -446,14 +455,14 @@ process_learn (struct controller_session *session) memory_pool_add_destructor (session->session_pool, (pool_destruct_func)g_object_unref, message); - /* free the parser (and the stream) */ - g_object_unref (parser); - #ifdef GMIME24 g_mime_message_foreach (message, mime_learn_foreach_callback, session); #else g_mime_message_foreach_part (message, mime_learn_foreach_callback, session); #endif + + /* free the parser (and the stream) */ + g_object_unref (parser); return 0; } |