Fix StripLeftRight

This commit is contained in:
Ricardo Luís Vaz Silva 2022-12-18 21:19:18 -03:00 committed by Christoph Oelckers
parent fb33a29400
commit 3ffbda5526

View file

@ -843,7 +843,7 @@ void FString::StripLeftRight ()
} }
for (j = max - 1; j >= i; --j) for (j = max - 1; j >= i; --j)
{ {
if (Chars[i] < 0 || !isspace((unsigned char)Chars[j])) if (Chars[j] < 0 || !isspace((unsigned char)Chars[j]))
break; break;
} }
if (i == 0 && j == max - 1) if (i == 0 && j == max - 1)
@ -863,7 +863,7 @@ void FString::StripLeftRight ()
{ {
FStringData *old = Data(); FStringData *old = Data();
AllocBuffer(j - i + 1); AllocBuffer(j - i + 1);
StrCopy(Chars, old->Chars(), j - i + 1); StrCopy(Chars, old->Chars() + i, j - i + 1);
old->Release(); old->Release();
} }
} }
@ -899,8 +899,8 @@ void FString::StripLeftRight (const char *charset)
else else
{ {
FStringData *old = Data(); FStringData *old = Data();
AllocBuffer (j - i); AllocBuffer (j - i + 1);
StrCopy (Chars, old->Chars(), j - i); StrCopy (Chars, old->Chars() + i, j - i + 1);
old->Release(); old->Release();
} }
} }