summaryrefslogtreecommitdiffstats
path: root/src/storage/phrase_index.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2010-08-16 14:05:35 +0800
committerPeng Wu <alexepico@gmail.com>2010-08-16 14:05:35 +0800
commitcf5571547919329d8dd09bd827fc00fe22008124 (patch)
treefc1790154efe015a9e89b778f47d6ba2688ede8b /src/storage/phrase_index.cpp
parent137145409fd1493e40f4482d89f71a0c7ebcc743 (diff)
downloadlibpinyin-cf5571547919329d8dd09bd827fc00fe22008124.tar.gz
libpinyin-cf5571547919329d8dd09bd827fc00fe22008124.tar.xz
libpinyin-cf5571547919329d8dd09bd827fc00fe22008124.zip
add a error check.
Diffstat (limited to 'src/storage/phrase_index.cpp')
-rw-r--r--src/storage/phrase_index.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/storage/phrase_index.cpp b/src/storage/phrase_index.cpp
index f87d834..7190615 100644
--- a/src/storage/phrase_index.cpp
+++ b/src/storage/phrase_index.cpp
@@ -98,7 +98,7 @@ bool SubPhraseIndex::add_unigram_frequency(phrase_token_t token, guint32 delta){
((token & PHRASE_MASK)
* sizeof(table_offset_t), &offset, sizeof(table_offset_t));
- if ( !result)
+ if ( !result )
return result;
if ( 0 == offset )
@@ -106,6 +106,10 @@ bool SubPhraseIndex::add_unigram_frequency(phrase_token_t token, guint32 delta){
result = m_phrase_content.get_content
(offset + sizeof(guint8) + sizeof(guint8), &freq, sizeof(guint32));
+
+ if ( !result )
+ return result;
+
//protect total_freq overflow
if ( delta > 0 && m_total_freq > m_total_freq + delta )
return false;