]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Do not crash if no words defined
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 14 Jan 2018 23:04:46 +0000 (23:04 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 14 Jan 2018 23:04:46 +0000 (23:04 +0000)
src/libmime/lang_detection.c

index 65f7d9b462749270d7185fc309598be7be8e77fa..f73bc7aeaa0a95c63e9f99b79410b77c10da15e6 100644 (file)
@@ -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,