aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/mime_encoding.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-29 23:17:44 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-29 23:18:06 +0100
commit112ed7966d7fcaf7f0a16a79b0af51e7d339e744 (patch)
tree37ed925e4d1d9c9c56af51bf0f377b5d46c86e0c /src/libmime/mime_encoding.c
parentb65379dd67aa524dd19e82ddf3528850675a74ce (diff)
downloadrspamd-112ed7966d7fcaf7f0a16a79b0af51e7d339e744.tar.gz
rspamd-112ed7966d7fcaf7f0a16a79b0af51e7d339e744.zip
[Minor] Fix byte array allocation
Diffstat (limited to 'src/libmime/mime_encoding.c')
-rw-r--r--src/libmime/mime_encoding.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/libmime/mime_encoding.c b/src/libmime/mime_encoding.c
index 2f0df38eb..d3f255740 100644
--- a/src/libmime/mime_encoding.c
+++ b/src/libmime/mime_encoding.c
@@ -651,18 +651,17 @@ rspamd_mime_text_part_maybe_convert (struct rspamd_task *task,
GByteArray *part_content;
rspamd_ftok_t charset_tok;
struct rspamd_mime_part *part = text_part->mime_part;
- gdouble t1, t2;
- t1 = rspamd_get_ticks (TRUE);
if (rspamd_str_has_8bit (text_part->raw.begin, text_part->raw.len)) {
text_part->flags |= RSPAMD_MIME_TEXT_PART_FLAG_8BIT;
}
- part_content = rspamd_mempool_alloc0 (task->task_pool, sizeof (GByteArray));
- part_content->data = rspamd_mempool_alloc (task->task_pool,
- text_part->parsed.len);
+ /* Allocate copy storage */
+ part_content = g_byte_array_sized_new (text_part->parsed.len);
memcpy (part_content->data, text_part->parsed.begin, text_part->parsed.len);
part_content->len = text_part->parsed.len;
+ rspamd_mempool_add_destructor (task->task_pool,
+ (rspamd_mempool_destruct_t)g_byte_array_unref, part_content);
if (rspamd_str_has_8bit (text_part->parsed.begin, text_part->parsed.len)) {
text_part->flags |= RSPAMD_MIME_TEXT_PART_FLAG_8BIT_ENCODED;
@@ -729,8 +728,6 @@ rspamd_mime_text_part_maybe_convert (struct rspamd_task *task,
rspamd_mime_text_part_ucs_from_utf (task, text_part);
rspamd_mime_text_part_normalise (task, text_part);
rspamd_mime_text_part_maybe_renormalise (task, text_part);
- t2 = rspamd_get_ticks (TRUE);
- msg_err_task ("conversion time: %.0f ticks", t2 - t1);
return;
}
@@ -752,6 +749,4 @@ rspamd_mime_text_part_maybe_convert (struct rspamd_task *task,
}
SET_PART_UTF (text_part);
- t2 = rspamd_get_ticks (TRUE);
- msg_err_task ("conversion time: %.0f ticks", t2 - t1);
}