From: Vsevolod Stakhov Date: Sun, 14 Jan 2018 23:04:46 +0000 (+0000) Subject: [Fix] Do not crash if no words defined X-Git-Tag: 1.7.0~279 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d90e890356c400980174267a59ca05cda5b7a1fd;p=rspamd.git [Fix] Do not crash if no words defined --- diff --git a/src/libmime/lang_detection.c b/src/libmime/lang_detection.c index 65f7d9b46..f73bc7aea 100644 --- a/src/libmime/lang_detection.c +++ b/src/libmime/lang_detection.c @@ -701,8 +701,13 @@ rspamd_language_detector_detect (struct rspamd_lang_detector *d, struct rspamd_lang_detector_res *cand; enum rspamd_language_detected_type r; + if (ucs_tokens->len == 0) { + return g_ptr_array_new (); + } + candidates = g_hash_table_new_full (rspamd_str_hash, rspamd_str_equal, NULL, g_free); + if (words_len < d->short_text_limit) { /* For short text, start directly from trigramms */ r = rspamd_language_detector_try_ngramm (d, ucs_tokens, rs_trigramm,