Skip to content

Commit d19ac45

Browse files
committed
fix crash in unigram model training
cherry pick 0fe7add, was blasted away in pilleye@53de765
1 parent d8f7418 commit d19ac45

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/unigram_model_trainer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ TrainerModel::SentencePieces Trainer::MakeSeedSentencePiecesInternal() {
273273
for (node_int_type i = 0; i < node_num; ++i) {
274274
const node_int_type offset = SA[L[i]];
275275
const node_int_type len = D[i];
276-
if (len <= 1) {
276+
if (len <= 1 || offset >= array.size() || offset + len >= array.size()) {
277277
continue;
278278
}
279279
const char32 *begin = &array[offset];

0 commit comments

Comments
 (0)