commit 06a167b: [Minor] Fuzzy: Fix stat command

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Jul 19 13:07:06 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-07-19 14:04:16 +0100
URL: https://github.com/rspamd/rspamd/commit/06a167bbf2c32fd861994ed51ac51e8b2e6f533c (HEAD -> master)

[Minor] Fuzzy: Fix stat command
Issue: #2989

---
 src/plugins/fuzzy_check.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 91d341507..a72dfbbb0 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -2668,12 +2668,12 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule,
 	struct rspamd_image *image;
 	struct fuzzy_cmd_io *io, *cur;
 	guint i, j;
-	GPtrArray *res;
+	GPtrArray *res = NULL;
 	gboolean check_part, fuzzy_check;
 
-	res = g_ptr_array_sized_new (MESSAGE_FIELD (task, parts)->len + 1);
-
 	if (c == FUZZY_STAT) {
+		res = g_ptr_array_sized_new (1);
+
 		io = fuzzy_cmd_stat (rule, c, flag, value, task->task_pool);
 		if (io) {
 			g_ptr_array_add (res, io);
@@ -2682,6 +2682,12 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule,
 		goto end;
 	}
 
+	if (task->message == NULL) {
+		goto end;
+	}
+
+	res = g_ptr_array_sized_new (MESSAGE_FIELD (task, parts)->len + 1);
+
 	PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, parts), i, mime_part) {
 		check_part = FALSE;
 		fuzzy_check = FALSE;
@@ -2740,7 +2746,7 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule,
 	}
 
 end:
-	if (res->len == 0) {
+	if (res && res->len == 0) {
 		g_ptr_array_free (res, TRUE);
 
 		return NULL;


More information about the Commits mailing list