]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] More divisions by zero
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 25 Dec 2021 20:17:08 +0000 (20:17 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 25 Dec 2021 20:33:55 +0000 (20:33 +0000)
src/libmime/lang_detection.c
src/plugins/chartable.c

index ba638982dfc399b5e36712daadf5b77001e11116..d0139919f1b707d1b7ff2fe5547cf54b25de4f99 100644 (file)
@@ -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) /
index 56fdac3a63804c242c51acc9880cefa18cf024af..745f51900d56164857182f060616fd3dcaa50f72 100644 (file)
@@ -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;