summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-06-24 10:56:46 +0800
committerPeng Wu <alexepico@gmail.com>2011-06-24 10:56:46 +0800
commit40565418ba236d4383b33d6d863375d881406803 (patch)
treeb9f30f93308f61848d45e76b1d11867feefad662 /utils
parentc6f13c8cd7991ed2de260ad105112ff77a5a0ff7 (diff)
downloadlibpinyin-40565418ba236d4383b33d6d863375d881406803.tar.gz
libpinyin-40565418ba236d4383b33d6d863375d881406803.tar.xz
libpinyin-40565418ba236d4383b33d6d863375d881406803.zip
add a check
Diffstat (limited to 'utils')
-rw-r--r--utils/training/gen_k_mixture_model.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/utils/training/gen_k_mixture_model.cpp b/utils/training/gen_k_mixture_model.cpp
index e09abe2..19dd102 100644
--- a/utils/training/gen_k_mixture_model.cpp
+++ b/utils/training/gen_k_mixture_model.cpp
@@ -298,6 +298,10 @@ static bool post_processing_unigram(KMixtureModelBigram * bigram,
KMixtureModelMagicHeader magic_header;
assert(bigram->get_magic_header(magic_header));
+ if ( magic_header.m_total_freq + delta < magic_header.m_total_freq ){
+ fprintf(stderr, "the m_total_freq in magic header overflows.\n");
+ return false;
+ }
magic_header.m_total_freq += total_freq;
assert(bigram->set_magic_header(magic_header));