]> source.dussan.org Git - rspamd.git/commitdiff
Fix memory corruption on fuzzy reload.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 14 Nov 2014 15:32:29 +0000 (15:32 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 14 Nov 2014 15:32:29 +0000 (15:32 +0000)
Reported by: @citrin

src/plugins/fuzzy_check.c

index a2dd959bc993fe90073fbae9ec1bed62ba697a23..d89798c878a21f6d7a16467d7e246a4d0ed7cf97 100644 (file)
@@ -219,11 +219,6 @@ parse_mime_types (const gchar *str)
                }
        }
 
-       if (res != NULL) {
-               rspamd_mempool_add_destructor (fuzzy_module_ctx->fuzzy_pool,
-                       (rspamd_mempool_destruct_t)g_list_free, res);
-       }
-
        return res;
 }
 
@@ -320,13 +315,17 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj)
                if (value->type == UCL_ARRAY) {
                        value = value->value.av;
                }
-               LL_FOREACH (value, cur)
-               {
+               LL_FOREACH (value, cur) {
                        rule->mime_types = g_list_concat (rule->mime_types,
                                        parse_mime_types (ucl_obj_tostring (cur)));
                }
        }
 
+       if (rule->mime_types != NULL) {
+               rspamd_mempool_add_destructor (fuzzy_module_ctx->fuzzy_pool,
+                       (rspamd_mempool_destruct_t)g_list_free, rule->mime_types);
+       }
+
        if ((value = ucl_object_find_key (obj, "max_score")) != NULL) {
                rule->max_score = ucl_obj_todouble (value);
        }