commit 880300d: [Fix] Plug memory leak

Vsevolod Stakhov vsevolod at highsecure.ru
Sat Oct 26 19:14:11 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-10-26 20:12:33 +0100
URL: https://github.com/rspamd/rspamd/commit/880300de81564ce2fa4664953fb2a42be9d0bcd0 (HEAD -> master)

[Fix] Plug memory leak

---
 src/libmime/scan_result.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/libmime/scan_result.c b/src/libmime/scan_result.c
index 6e6b30826..2ffe6e7ff 100644
--- a/src/libmime/scan_result.c
+++ b/src/libmime/scan_result.c
@@ -521,8 +521,11 @@ rspamd_task_add_result_option (struct rspamd_task *task,
 	gint r;
 
 	if (s && val) {
-		if (s->options && !(s->sym &&
-				(s->sym->flags & RSPAMD_SYMBOL_FLAG_ONEPARAM)) &&
+		if (!s->options) {
+			s->options = kh_init (rspamd_options_hash);
+		}
+
+		if (!(s->sym && (s->sym->flags & RSPAMD_SYMBOL_FLAG_ONEPARAM)) &&
 				kh_size (s->options) < task->cfg->default_max_shots) {
 			/* Append new options */
 			k = kh_get (rspamd_options_hash, s->options, val);
@@ -540,7 +543,6 @@ rspamd_task_add_result_option (struct rspamd_task *task,
 			}
 		}
 		else {
-			s->options = kh_init (rspamd_options_hash);
 			opt = rspamd_mempool_alloc0 (task->task_pool, sizeof (*opt));
 			opt_cpy = rspamd_mempool_strdup (task->task_pool, val);
 			k = kh_put (rspamd_options_hash, s->options, opt_cpy, &r);


More information about the Commits mailing list