commit e7d92f9: [Minor] Another try to plug a leak

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jun 26 14:07:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-06-26 15:00:52 +0100
URL: https://github.com/rspamd/rspamd/commit/e7d92f9a0a4a90778861b3247297a60e7bf464c9 (HEAD -> master)

[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);
 			}
 		}
 


More information about the Commits mailing list