aboutsummaryrefslogtreecommitdiffstats
path: root/src/classifiers
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-02-09 17:22:58 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-02-09 17:22:58 +0300
commitc07cd514e4ea635a59937cf703107ab075e92400 (patch)
tree85084005fe4f3e43962c47782080bf47f33db9ca /src/classifiers
parent092996070fffeb3d6aabb1065d0382d7a24f604e (diff)
downloadrspamd-c07cd514e4ea635a59937cf703107ab075e92400.tar.gz
rspamd-c07cd514e4ea635a59937cf703107ab075e92400.zip
* Avoid division by zero
Diffstat (limited to 'src/classifiers')
-rw-r--r--src/classifiers/winnow.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/classifiers/winnow.c b/src/classifiers/winnow.c
index 5775a7997..4b286eb8f 100644
--- a/src/classifiers/winnow.c
+++ b/src/classifiers/winnow.c
@@ -96,7 +96,14 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t *pool, char *statfi
}
g_tree_foreach (input, classify_callback, &data);
- *res = scale * (data.sum / data.count);
+
+ if (data.count != 0) {
+ *res = scale * (data.sum / data.count);
+ }
+ else {
+ *res = 0;
+ }
+
g_hash_table_insert (ctx->results, statfile, res);
}