Skip to content

Commit e3f5284

Browse files
committed
fix(script_translator): excluded words cause crashes
1 parent de4700e commit e3f5284

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/rime/gear/script_translator.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ inline static bool prefer_user_phrase(
569569
}
570570

571571
bool ScriptTranslation::PrepareCandidate() {
572+
iter_incremented:
572573
if (exhausted()) {
573574
candidate_source_ = kUninitialized;
574575
candidate_ = nullptr;
@@ -615,6 +616,10 @@ bool ScriptTranslation::PrepareCandidate() {
615616
})) {
616617
UserDictEntryIterator& uter = user_phrase_iter_->second;
617618
const auto& entry = uter.Peek();
619+
if (!entry) {
620+
++user_phrase_iter_;
621+
goto iter_incremented;
622+
}
618623
DLOG(INFO) << "user phrase '" << entry->text
619624
<< "', code length: " << user_phrase_code_length;
620625
candidate_source_ = kUserPhrase;
@@ -629,6 +634,10 @@ bool ScriptTranslation::PrepareCandidate() {
629634
} else if (phrase_code_length > 0) {
630635
DictEntryIterator& iter = phrase_iter_->second;
631636
const auto& entry = iter.Peek();
637+
if (!entry) {
638+
++phrase_iter_;
639+
goto iter_incremented;
640+
}
632641
DLOG(INFO) << "phrase '" << entry->text
633642
<< "', code length: " << phrase_code_length;
634643
candidate_source_ = kSysPhrase;

0 commit comments

Comments
 (0)