Skip to content

Commit 787b63f

Browse files
committed
#3922 Crash on removeStringNoUndo
1 parent e01c447 commit 787b63f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

indra/llui/lltextbase.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,14 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s
10691069

10701070
S32 LLTextBase::removeStringNoUndo(S32 pos, S32 length)
10711071
{
1072+
S32 text_length = (S32)getLength();
1073+
if (pos >= text_length || pos < 0)
1074+
{
1075+
return 0; // nothing to remove
1076+
}
1077+
// Clamp length to not go past the end of the text
1078+
length = std::min(length, text_length - pos);
1079+
10721080
beforeValueChange();
10731081
segment_set_t::iterator seg_iter = getSegIterContaining(pos);
10741082
while(seg_iter != mSegments.end())

0 commit comments

Comments
 (0)