From: Vsevolod Stakhov Date: Mon, 15 May 2017 15:33:15 +0000 (+0100) Subject: [Fix] Do not set bayes probability if we don't use it X-Git-Tag: 1.5.8~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=20891bab4729c84c92dd920cbde4d236dcd0a7de;p=rspamd.git [Fix] Do not set bayes probability if we don't use it --- diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c index 8116e508d..af25195b0 100644 --- a/src/libstat/classifiers/bayes.c +++ b/src/libstat/classifiers/bayes.c @@ -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++) {