summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-11-25 12:24:35 +0800
committerPeng Wu <alexepico@gmail.com>2013-11-29 15:09:14 +0800
commit605e8ff9e28f372c43e5f133fe8a540857f819ae (patch)
tree14932646b34abf3d035089640d5ac00421e96222
parent8a165c91b93eb47fa7be195c7b78fdba46baaa16 (diff)
downloadlibpinyin-605e8ff9e28f372c43e5f133fe8a540857f819ae.tar.gz
libpinyin-605e8ff9e28f372c43e5f133fe8a540857f819ae.tar.xz
libpinyin-605e8ff9e28f372c43e5f133fe8a540857f819ae.zip
fixes crash
-rw-r--r--src/pinyin.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index 1f27f72..975859d 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -1792,14 +1792,19 @@ bool pinyin_guess_predicted_candidates(pinyin_instance_t * instance,
for (size_t len = MAX_PHRASE_LENGTH; len > 0; --len) {
/* append items. */
for (size_t k = 0; k < tokens->len; ++k){
- phrase_token_t token = g_array_index(tokens, phrase_token_t, k);
- phrase_index->get_phrase_item(token, cached_item);
+ BigramPhraseItemWithCount * phrase_item = &g_array_index
+ (tokens, BigramPhraseItemWithCount, k);
+
+ int result = phrase_index->get_phrase_item
+ (phrase_item->m_token, cached_item);
+ if (ERROR_NO_SUB_PHRASE_INDEX == result)
+ continue;
if (len != cached_item.get_phrase_length())
continue;
lookup_candidate_t item;
item.m_candidate_type = PREDICTED_CANDIDATE;
- item.m_token = token;
+ item.m_token = phrase_item->m_token;
g_array_append_val(items, item);
}