summaryrefslogtreecommitdiffstats
path: root/src/pinyin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pinyin.cpp')
-rw-r--r--src/pinyin.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index 7462c8e..1c31b1a 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -345,12 +345,15 @@ bool pinyin_iterator_add_phrase(import_iterator_t * iter,
FacadeChewingTable * & pinyin_table = context->m_pinyin_table;
FacadePhraseIndex * & phrase_index = context->m_phrase_index;
+ bool result = false;
+
+ if (NULL == pinyin)
+ return result;
+
/* check whether the phrase exists in phrase table */
glong len_phrase = 0;
ucs4_t * ucs4_phrase = g_utf8_to_ucs4(phrase, -1, NULL, &len_phrase, NULL);
- bool result = false;
-
pinyin_option_t options = PINYIN_CORRECT_ALL | USE_TONE;
FullPinyinParser2 parser;
ChewingKeyVector keys =
@@ -364,7 +367,7 @@ bool pinyin_iterator_add_phrase(import_iterator_t * iter,
if (len_phrase != keys->len)
return result;
- if (len_phrase >= MAX_PHRASE_LENGTH)
+ if (0 == len_phrase || len_phrase >= MAX_PHRASE_LENGTH)
return result;
phrase_token_t token = null_token;