aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-21 12:47:40 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-21 12:47:40 +0100
commita3374a6c7bc9f26d0ad07ef260d3528bd77105fb (patch)
treeff877e66e77960164eaa1f00ac9e21ebd8e970ec /src
parent97f3f341e396a2df2d00e5a3491e2eb4bc882547 (diff)
downloadrspamd-a3374a6c7bc9f26d0ad07ef260d3528bd77105fb.tar.gz
rspamd-a3374a6c7bc9f26d0ad07ef260d3528bd77105fb.zip
Fix memory issues with tokens normalization.
Diffstat (limited to 'src')
-rw-r--r--src/libmime/message.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index e6f0d0a2b..786510822 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -1184,6 +1184,7 @@ rspamd_normalize_text_part (struct rspamd_task *task,
struct sb_stemmer *stem = NULL;
rspamd_fstring_t *w;
const guchar *r;
+ gchar *temp_word;
guint i, nlen;
GArray *tmp;
@@ -1210,10 +1211,15 @@ rspamd_normalize_text_part (struct rspamd_task *task,
if (stem != NULL && r != NULL) {
nlen = strlen (r);
nlen = MIN (nlen, w->len);
+ w->begin = rspamd_mempool_alloc (task->task_pool, nlen);
memcpy (w->begin, r, nlen);
w->len = nlen;
}
else {
+ temp_word = w->begin;
+ w->begin = rspamd_mempool_alloc (task->task_pool, w->len);
+ memcpy (w->begin, temp_word, w->len);
+
if (IS_PART_UTF (part)) {
rspamd_str_lc_utf8 (w->begin, w->len);
}