summaryrefslogtreecommitdiffstats
path: root/src/storage
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-07-06 15:37:55 +0800
committerPeng Wu <alexepico@gmail.com>2016-07-06 15:37:55 +0800
commitf7a44387af9407d3d9d3224b5eec5077fe141445 (patch)
tree54fc03de98f9360594bd80b16e8b4dc96c835656 /src/storage
parentbc906ecfbf52f98fa7174cb991e2ccb67293f2e6 (diff)
downloadlibpinyin-f7a44387af9407d3d9d3224b5eec5077fe141445.tar.gz
libpinyin-f7a44387af9407d3d9d3224b5eec5077fe141445.tar.xz
libpinyin-f7a44387af9407d3d9d3224b5eec5077fe141445.zip
fixes empty input
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/phonetic_key_matrix.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/storage/phonetic_key_matrix.cpp b/src/storage/phonetic_key_matrix.cpp
index 5b6ec5b..856738f 100644
--- a/src/storage/phonetic_key_matrix.cpp
+++ b/src/storage/phonetic_key_matrix.cpp
@@ -30,7 +30,11 @@ namespace pinyin{
bool fill_matrix(PhoneticKeyMatrix * matrix,
ChewingKeyVector keys,
ChewingKeyRestVector key_rests) {
+ matrix->clear_all();
+
assert(keys->len == key_rests->len);
+ if (0 == keys->len)
+ return false;
const ChewingKey * key = NULL;
const ChewingKeyRest * key_rest = NULL;
@@ -79,6 +83,8 @@ bool resplit_step(pinyin_option_t options,
return false;
size_t length = matrix->size();
+ if (0 == length)
+ return false;
GArray * keys = g_array_new(TRUE, TRUE, sizeof(ChewingKey));
GArray * key_rests = g_array_new(TRUE, TRUE, sizeof(ChewingKeyRest));
@@ -159,6 +165,8 @@ bool inner_split_step(pinyin_option_t options,
return false;
size_t length = matrix->size();
+ if (0 == length)
+ return false;
GArray * keys = g_array_new(TRUE, TRUE, sizeof(ChewingKey));
GArray * key_rests = g_array_new(TRUE, TRUE, sizeof(ChewingKeyRest));
@@ -214,6 +222,8 @@ bool fuzzy_syllable_step(pinyin_option_t options,
return false;
size_t length = matrix->size();
+ if (0 == length)
+ return false;
GArray * keys = g_array_new(TRUE, TRUE, sizeof(ChewingKey));
GArray * key_rests = g_array_new(TRUE, TRUE, sizeof(ChewingKeyRest));