From cf5571547919329d8dd09bd827fc00fe22008124 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 16 Aug 2010 14:05:35 +0800 Subject: add a error check. --- src/storage/phrase_index.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/storage/phrase_index.cpp') 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; -- cgit