fixes crash
authorPeng Wu <alexepico@gmail.com>
Mon, 18 Feb 2013 06:36:13 +0000 (14:36 +0800)
committerPeng Wu <alexepico@gmail.com>
Mon, 18 Feb 2013 06:36:13 +0000 (14:36 +0800)
src/storage/phrase_index.cpp

index 3df14f5..5904549 100644 (file)
@@ -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) {