summaryrefslogtreecommitdiff
path: root/indra/llui/lllineeditor.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2025-05-28 21:11:23 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2025-05-28 21:11:23 +0300
commitd3bd73ab923b8010bb395505b95bcc38b661162e (patch)
tree56b5fadba1f247fc42b6d3a3062154d61a43abac /indra/llui/lllineeditor.cpp
parent3af711e6da9d0004ce1b565bfadee634f087b89a (diff)
parentde8275b14b30bf754cdba1da867cb2e6c2783639 (diff)
Merge branch 'main' into marchcat/slua-editor-merge
# Conflicts: # .github/workflows/build.yaml # indra/newview/llmeshrepository.cpp # indra/newview/llmeshrepository.h # indra/newview/llpreviewscript.h
Diffstat (limited to 'indra/llui/lllineeditor.cpp')
-rw-r--r--indra/llui/lllineeditor.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 66b274c33f..45dab88e87 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -2505,9 +2505,24 @@ void LLLineEditor::resetPreedit()
if (hasPreeditString())
{
const S32 preedit_pos = mPreeditPositions.front();
- mText.erase(preedit_pos, mPreeditPositions.back() - preedit_pos);
- mText.insert(preedit_pos, mPreeditOverwrittenWString);
- setCursor(preedit_pos);
+ const S32 end = mPreeditPositions.back();
+ const S32 len = end - preedit_pos;
+ const S32 size = mText.length();
+ if (preedit_pos < size
+ && end <= size
+ && preedit_pos >= 0
+ && len > 0)
+ {
+ mText.erase(preedit_pos, len);
+ mText.insert(preedit_pos, mPreeditOverwrittenWString);
+ setCursor(preedit_pos);
+ }
+ else
+ {
+ LL_WARNS() << "Index out of bounds. Start: " << preedit_pos
+ << ", end:" << end
+ << ", full string length: " << size << LL_ENDL;
+ }
mPreeditWString.clear();
mPreeditOverwrittenWString.clear();