summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-02-18 14:36:13 +0800
committerPeng Wu <alexepico@gmail.com>2013-02-18 14:36:13 +0800
commit36ef85182a682e35a1a7ba7d79292c69fa184b38 (patch)
tree4329e24978e54741916287a8d35f2c4d1399919a /src
parenta8421c0fb6a25e4af628d43841cbb8b7cca81997 (diff)
downloadlibpinyin-36ef85182a682e35a1a7ba7d79292c69fa184b38.tar.gz
libpinyin-36ef85182a682e35a1a7ba7d79292c69fa184b38.tar.xz
libpinyin-36ef85182a682e35a1a7ba7d79292c69fa184b38.zip
fixes crash
Diffstat (limited to 'src')
-rw-r--r--src/storage/phrase_index.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/storage/phrase_index.cpp b/src/storage/phrase_index.cpp
index 3df14f5..5904549 100644
--- a/src/storage/phrase_index.cpp
+++ b/src/storage/phrase_index.cpp
@@ -564,6 +564,13 @@ int SubPhraseIndex::get_range(/* out */ PhraseIndexRange & range){
const table_offset_t * begin = (const table_offset_t *)m_phrase_index.begin();
const table_offset_t * end = (const table_offset_t *)m_phrase_index.end();
+ if (begin == end) {
+ /* skip empty sub phrase index. */
+ range.m_range_begin = 1;
+ range.m_range_end = 1;
+ return ERROR_OK;
+ }
+
/* remove trailing zeros. */
const table_offset_t * poffset = 0;
for (poffset = end - 1; poffset >= begin + 1; --poffset) {