#3922 Crash on removeStringNoUndo

master
Andrey Kleshchev 2025-08-20 20:33:59 +03:00 committed by Andrey Kleshchev
parent e01c447745
commit 787b63f4c2
1 changed files with 8 additions and 0 deletions

View File

@ -1069,6 +1069,14 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s
S32 LLTextBase::removeStringNoUndo(S32 pos, S32 length)
{
S32 text_length = (S32)getLength();
if (pos >= text_length || pos < 0)
{
return 0; // nothing to remove
}
// Clamp length to not go past the end of the text
length = std::min(length, text_length - pos);
beforeValueChange();
segment_set_t::iterator seg_iter = getSegIterContaining(pos);
while(seg_iter != mSegments.end())