]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
* Avoid division by zero
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 9 Feb 2009 14:22:58 +0000 (17:22 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 9 Feb 2009 14:22:58 +0000 (17:22 +0300)
src/classifiers/winnow.c

index 5775a79975501cb80335499ac7b0304352ffaac5..4b286eb8f6e92b0d8804503852a8cfa97fcf49f5 100644 (file)
@@ -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);
 }