Skip to content

Commit ff7acdc

Browse files
TsinamLeunglotem
authored andcommittedJan 9, 2021
fix(table_translator): index out of bound access in string
when trying to add blank to preedit then increase pos, might lead to input[pos - 1] out of bound. `pos` is tracking string variable `preedit`, they should be updated in sync. checking delimiters at word ending should also refer to `preedit` instead of the unchanged `input_`.
1 parent 1fad0b8 commit ff7acdc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎src/rime/gear/table_translator.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ void SentenceTranslation::PrepareSentence() {
500500
// split syllables
501501
size_t pos = 0;
502502
for (int len : sentence_->word_lengths()) {
503-
if (pos > 0 && delimiters.find(input_[pos - 1]) == string::npos) {
503+
if (pos > 0 && delimiters.find(preedit[pos - 1]) == string::npos) {
504504
preedit.insert(pos, 1, ' ');
505505
++pos;
506506
}

0 commit comments

Comments
 (0)