From 4e3ac80a4680a10430e3ec798d9c5636bc2f2131 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 26 Nov 2018 13:50:06 +0000 Subject: [PATCH] [Minor] Fix indefinite loop in language detector --- src/libmime/lang_detection.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libmime/lang_detection.c b/src/libmime/lang_detection.c index e80a13e29..a8ad1d57c 100644 --- a/src/libmime/lang_detection.c +++ b/src/libmime/lang_detection.c @@ -931,12 +931,11 @@ rspamd_language_detector_random_select (GArray *ucs_tokens, guint nwords, tok = &g_array_index (ucs_tokens, rspamd_stat_token_t, sel); /* Filter bad tokens */ - if (tok->unicode.len >= 2) { - if (u_isalpha (tok->unicode.begin[0]) && + if (tok->unicode.len >= 2 && + u_isalpha (tok->unicode.begin[0]) && u_isalpha (tok->unicode.begin[tok->unicode.len - 1])) { - offsets_out[out_idx] = sel; - break; - } + offsets_out[out_idx] = sel; + break; } else { ntries ++; -- 2.39.5