diff options
author | Peng Wu <alexepico@gmail.com> | 2010-09-01 17:04:38 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2010-09-01 17:04:38 +0800 |
commit | bee691f0e31f0b661f7c2c16230163dd7d526d4c (patch) | |
tree | f0a4e2be996a0c236426e33b0bf446be07eaae22 /src/storage/pinyin_large_table.cpp | |
parent | cdb3ae7a7bab2970eedae28ee7d1a387847f51fd (diff) | |
download | libpinyin-bee691f0e31f0b661f7c2c16230163dd7d526d4c.tar.gz libpinyin-bee691f0e31f0b661f7c2c16230163dd7d526d4c.tar.xz libpinyin-bee691f0e31f0b661f7c2c16230163dd7d526d4c.zip |
add safe check for load_text.
Diffstat (limited to 'src/storage/pinyin_large_table.cpp')
-rw-r--r-- | src/storage/pinyin_large_table.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/storage/pinyin_large_table.cpp b/src/storage/pinyin_large_table.cpp index 07f643e..a5ed998 100644 --- a/src/storage/pinyin_large_table.cpp +++ b/src/storage/pinyin_large_table.cpp @@ -483,11 +483,14 @@ bool PinyinLargeTable::load_text(FILE * infile){ phrase_token_t token; size_t freq; - while ( !feof(infile)){ + while ( !feof(infile) ) { fscanf(infile, "%s", pinyin); fscanf(infile, "%s", phrase); fscanf(infile, "%ld", &token); fscanf(infile, "%ld", &freq); + + if ( feof(infile) ) + break; PinyinDefaultParser parser; NullPinyinValidator validator; |