aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-01-14 23:04:46 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-01-14 23:04:46 +0000
commitd90e890356c400980174267a59ca05cda5b7a1fd (patch)
treea99950bb0a723250cd09cd3400ae27ad23952f3a /src
parent3178969987c7d61219d04274c39dd4a452e99bb4 (diff)
downloadrspamd-d90e890356c400980174267a59ca05cda5b7a1fd.tar.gz
rspamd-d90e890356c400980174267a59ca05cda5b7a1fd.zip
[Fix] Do not crash if no words defined
Diffstat (limited to 'src')
-rw-r--r--src/libmime/lang_detection.c5
1 files changed, 5 insertions, 0 deletions
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,