summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2018-09-10 15:15:36 +0800
committerPeng Wu <alexepico@gmail.com>2018-09-10 15:15:36 +0800
commit0fadbc2aaf01da5f83fed00238357e8181d4a051 (patch)
tree96325fe6e6f1e1816374643c80ca44a3a4d3c3f1
parent9bd208f580e907090037352dc39fbb1f95065eaf (diff)
downloadlibpinyin-0fadbc2aaf01da5f83fed00238357e8181d4a051.zip
libpinyin-0fadbc2aaf01da5f83fed00238357e8181d4a051.tar.gz
libpinyin-0fadbc2aaf01da5f83fed00238357e8181d4a051.tar.xz
add safe guard to pinyin_guess_predicted_candidates function
-rw-r--r--src/pinyin.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index b91f2b3..2bfc0b8 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -1889,6 +1889,9 @@ bool pinyin_guess_predicted_candidates(pinyin_instance_t * instance,
break;
}
+ if (0 == merged_gram.get_length())
+ return false;
+
/* retrieve all items. */
BigramPhraseWithCountArray tokens = g_array_new
(FALSE, FALSE, sizeof(BigramPhraseItemWithCount));