From: Vsevolod Stakhov Date: Mon, 26 Nov 2018 13:50:06 +0000 (+0000) Subject: [Minor] Fix indefinite loop in language detector X-Git-Tag: 1.8.3~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e3ac80a4680a10430e3ec798d9c5636bc2f2131;p=thirdparty%2Frspamd.git [Minor] Fix indefinite loop in language detector --- diff --git a/src/libmime/lang_detection.c b/src/libmime/lang_detection.c index e80a13e290..a8ad1d57c9 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 ++;