]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Do not set bayes probability if we don't use it
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 15 May 2017 15:33:15 +0000 (16:33 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 May 2017 11:28:10 +0000 (12:28 +0100)
src/libstat/classifiers/bayes.c

index 8116e508d8d4e2d1a5437af0ebaf35ee2375b8ad..af25195b0f1f3f90b2db0a8768574b0dca674ef1 100644 (file)
@@ -356,10 +356,6 @@ bayes_classify (struct rspamd_classifier * ctx,
                }
        }
 
-       pprob = rspamd_mempool_alloc (task->task_pool, sizeof (*pprob));
-       *pprob = final_prob;
-       rspamd_mempool_set_variable (task->task_pool, "bayes_prob", pprob, NULL);
-
        if (ctx->cfg->min_tokens > 0 &&
                        cl.text_tokens < (gint)(ctx->cfg->min_tokens * 0.1)) {
                msg_info_bayes ("ignore bayes probability %.2f since we have "
@@ -371,6 +367,10 @@ bayes_classify (struct rspamd_classifier * ctx,
                return TRUE;
        }
 
+       pprob = rspamd_mempool_alloc (task->task_pool, sizeof (*pprob));
+       *pprob = final_prob;
+       rspamd_mempool_set_variable (task->task_pool, "bayes_prob", pprob, NULL);
+
        if (cl.processed_tokens > 0 && fabs (final_prob - 0.5) > 0.05) {
                /* Now we can have exactly one HAM and exactly one SPAM statfiles per classifier */
                for (i = 0; i < ctx->statfiles_ids->len; i++) {