summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llui/lltextbase.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 8839afb60d..4c9c2781f2 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -605,7 +605,8 @@ void LLTextBase::drawText()
// Find the start of the first word
U32 word_start = seg_start, word_end = -1;
- while ( (word_start < wstrText.length()) && (!LLStringOps::isAlpha(wstrText[word_start])) )
+ U32 text_length = wstrText.length();
+ while ( (word_start < text_length) && (!LLStringOps::isAlpha(wstrText[word_start])) )
{
word_start++;
}
@@ -627,11 +628,15 @@ void LLTextBase::drawText()
break;
}
- // Don't process words shorter than 3 characters
- std::string word = wstring_to_utf8str(wstrText.substr(word_start, word_end - word_start));
- if ( (word.length() >= 3) && (!LLSpellChecker::instance().checkSpelling(word)) )
+ if (word_start < text_length && word_end <= text_length && word_end > word_start)
{
- mMisspellRanges.push_back(std::pair<U32, U32>(word_start, word_end));
+ std::string word = wstring_to_utf8str(wstrText.substr(word_start, word_end - word_start));
+
+ // Don't process words shorter than 3 characters
+ if ( (word.length() >= 3) && (!LLSpellChecker::instance().checkSpelling(word)) )
+ {
+ mMisspellRanges.push_back(std::pair<U32, U32>(word_start, word_end));
+ }
}
// Find the start of the next word