From e7d92f9a0a4a90778861b3247297a60e7bf464c9 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 26 Jun 2019 15:00:52 +0100 Subject: [PATCH] [Minor] Another try to plug a leak --- src/libmime/lang_detection.c | 4 ++++ src/libmime/message.c | 8 ++++++++ src/libserver/task.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libmime/lang_detection.c b/src/libmime/lang_detection.c index 3f2a50134..7096da585 100644 --- a/src/libmime/lang_detection.c +++ b/src/libmime/lang_detection.c @@ -1828,6 +1828,10 @@ rspamd_language_detector_detect (struct rspamd_task *task, d->total_occurencies++; } + if (part->languages != NULL) { + g_ptr_array_unref (part->languages); + } + part->languages = result; ret = TRUE; } diff --git a/src/libmime/message.c b/src/libmime/message.c index cd3772c78..482287769 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -1424,10 +1424,18 @@ rspamd_message_process (struct rspamd_task *task) if (sel->language && sel->language[0]) { /* Propagate language */ if (sel == p1) { + if (p2->languages) { + g_ptr_array_unref (p2->languages); + } + p2->language = sel->language; p2->languages = g_ptr_array_ref (sel->languages); } else { + if (p1->languages) { + g_ptr_array_unref (p1->languages); + } + p1->language = sel->language; p1->languages = g_ptr_array_ref (sel->languages); } diff --git a/src/libserver/task.c b/src/libserver/task.c index 4017b0094..04be61744 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -271,7 +271,7 @@ rspamd_task_free (struct rspamd_task *task) g_array_free (tp->normalized_hashes, TRUE); } if (tp->languages) { - g_ptr_array_free (tp->languages, TRUE); + g_ptr_array_unref (tp->languages); } } -- 2.39.5