diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-02-09 17:22:58 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-02-09 17:22:58 +0300 |
commit | c07cd514e4ea635a59937cf703107ab075e92400 (patch) | |
tree | 85084005fe4f3e43962c47782080bf47f33db9ca /src/classifiers | |
parent | 092996070fffeb3d6aabb1065d0382d7a24f604e (diff) | |
download | rspamd-c07cd514e4ea635a59937cf703107ab075e92400.tar.gz rspamd-c07cd514e4ea635a59937cf703107ab075e92400.zip |
* Avoid division by zero
Diffstat (limited to 'src/classifiers')
-rw-r--r-- | src/classifiers/winnow.c | 9 |
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); } |