From d90e890356c400980174267a59ca05cda5b7a1fd Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 14 Jan 2018 23:04:46 +0000 Subject: [PATCH] [Fix] Do not crash if no words defined --- src/libmime/lang_detection.c | 5 +++++ 1 file changed, 5 insertions(+) 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, -- 2.39.5