diff --git a/src/gui/value/text.cpp b/src/gui/value/text.cpp index afa5b759..6d84f2dd 100644 --- a/src/gui/value/text.cpp +++ b/src/gui/value/text.cpp @@ -519,10 +519,11 @@ String spellcheck_word_at(const String& str, size_t start) { void spellcheck_language_at(const String& str, size_t error_pos, SpellChecker** out) { String tag = tag_at(str,error_pos); size_t pos = min(tag.find_first_of(_(':')), tag.size()-1); - size_t pos2 = min(tag.find_first_of(_(':'),pos+1), tag.size()-1); + size_t pos2 = min(tag.find_first_of(_(':'),pos+1), tag.size()); String language = tag.substr(pos+1,pos2-pos-1); if (language.empty()) return; out[0] = &SpellChecker::get(language); + if (pos2 >= tag.size()) return; String extra = tag.substr(pos2+1); if (extra.empty()) return; out[1] = &SpellChecker::get(extra,language);