Skip to content

Commit

Permalink
fixed crash bug in unigram model training
Browse files Browse the repository at this point in the history
  • Loading branch information
taku910 committed Jan 28, 2024
1 parent 41c4b7f commit 0fe7add
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/unigram_model_trainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ TrainerModel::SentencePieces Trainer::MakeSeedSentencePiecesInternal() {
for (node_int_type i = 0; i < node_num; ++i) {
const node_int_type offset = SA[L[i]];
const node_int_type len = D[i];
if (len <= 1) {
if (len <= 1 || offset >= array.size() || offset + len >= array.size()) {
continue;
}
const char32 *begin = &array[offset];
Expand Down

0 comments on commit 0fe7add

Please sign in to comment.