]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix indefinite loop in language detector
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 26 Nov 2018 13:50:06 +0000 (13:50 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 26 Nov 2018 13:50:06 +0000 (13:50 +0000)
src/libmime/lang_detection.c

index e80a13e290a9424002a235c936186de948025099..a8ad1d57c99676a89ccaf4edb9dfcea9cf8bd98d 100644 (file)
@@ -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 ++;