commit 2d8c7bf: [Minor] More divisions by zero
Vsevolod Stakhov
vsevolod at highsecure.ru
Sat Dec 25 20:35:05 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-12-25 20:17:08 +0000
URL: https://github.com/rspamd/rspamd/commit/2d8c7bfb4e011bdcd4a632061e0f759abccff40a
[Minor] More divisions by zero
---
src/libmime/lang_detection.c | 4 ++++
src/plugins/chartable.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/libmime/lang_detection.c b/src/libmime/lang_detection.c
index ba638982d..d0139919f 100644
--- a/src/libmime/lang_detection.c
+++ b/src/libmime/lang_detection.c
@@ -1308,6 +1308,10 @@ rspamd_language_detector_cmp_heuristic (gconstpointer a, gconstpointer b,
gdouble adj;
gdouble proba_adjusted, probb_adjusted, freqa, freqb;
+ if (cbd->d->total_occurencies == 0) {
+ return 0;
+ }
+
freqa = ((gdouble)canda->elt->occurencies) /
(gdouble)cbd->d->total_occurencies;
freqb = ((gdouble)candb->elt->occurencies) /
diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c
index 56fdac3a6..745f51900 100644
--- a/src/plugins/chartable.c
+++ b/src/plugins/chartable.c
@@ -674,7 +674,7 @@ chartable_symbol_callback (struct rspamd_task *task,
ignore_diacritics = TRUE;
}
- if (task->meta_words != NULL) {
+ if (task->meta_words != NULL && task->meta_words->len > 0) {
rspamd_stat_token_t *w;
gdouble cur_score = 0;
gsize arlen = task->meta_words->len;
More information about the Commits
mailing list