summaryrefslogtreecommitdiffstats
path: root/src/libmime
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-09-05 18:05:29 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-09-05 18:05:29 +0100
commit279b8f0e758a83179d96d2ff9b505da06645e956 (patch)
tree0ea7518adeb07d2fbcad5e3ecd8e4cf7c37ad659 /src/libmime
parenta64ce9b4245153e68fbbcd9c6610b9c1ccf76493 (diff)
downloadrspamd-279b8f0e758a83179d96d2ff9b505da06645e956.tar.gz
rspamd-279b8f0e758a83179d96d2ff9b505da06645e956.zip
[Minor] Fix processing of empty parts
Diffstat (limited to 'src/libmime')
-rw-r--r--src/libmime/message.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index 1df980758..effcff834 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -502,24 +502,31 @@ rspamd_normalize_text_part (struct rspamd_task *task,
struct rspamd_process_exception *ex;
/* Strip newlines */
- part->utf_stripped_content = g_byte_array_sized_new (part->utf_content->len);
- part->newlines = g_ptr_array_sized_new (128);
- p = (const gchar *)part->utf_content->data;
- end = p + part->utf_content->len;
-
- rspamd_strip_newlines_parse (p, end, part);
-
- for (i = 0; i < part->newlines->len; i ++) {
- ex = rspamd_mempool_alloc (task->task_pool, sizeof (*ex));
- off = (goffset)g_ptr_array_index (part->newlines, i);
- g_ptr_array_index (part->newlines, i) = (gpointer)(goffset)
- (part->utf_stripped_content->data + off);
- ex->pos = off;
- ex->len = 0;
- ex->type = RSPAMD_EXCEPTION_NEWLINE;
- part->exceptions = g_list_prepend (part->exceptions, ex);
+ if (IS_PART_EMPTY (part)) {
+ part->utf_stripped_content = g_byte_array_new ();
+ }
+ else {
+ part->utf_stripped_content = g_byte_array_sized_new (part->utf_content->len);
+
+ p = (const gchar *)part->utf_content->data;
+ end = p + part->utf_content->len;
+
+ rspamd_strip_newlines_parse (p, end, part);
+
+ for (i = 0; i < part->newlines->len; i ++) {
+ ex = rspamd_mempool_alloc (task->task_pool, sizeof (*ex));
+ off = (goffset)g_ptr_array_index (part->newlines, i);
+ g_ptr_array_index (part->newlines, i) = (gpointer)(goffset)
+ (part->utf_stripped_content->data + off);
+ ex->pos = off;
+ ex->len = 0;
+ ex->type = RSPAMD_EXCEPTION_NEWLINE;
+ part->exceptions = g_list_prepend (part->exceptions, ex);
+ }
}
+ part->newlines = g_ptr_array_sized_new (128);
+
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t) free_byte_array_callback,
part->utf_stripped_content);