Fixed a bug on zero padding the string's byte content.

This commit is contained in:
2022-07-07 23:07:38 -05:00
parent b1d79d7b7e
commit 9873ef9198
+2 -3
View File
@@ -110,9 +110,8 @@ void TStringRemoveRange(int startIndex, int count, TString* string) {
for (glyphCount = 0; glyphCount < count; glyphCount++) endByte += GetGlyphByteWidth(string->Characters[endByte]);
memset(&string->Characters[startByte], '\0', endByte - startByte);
if (endByte == string->ByteCount) {
memset(&string->Characters[startByte], '\0', endByte - startByte);
string->Length -= glyphCount;
string->ByteCount -= endByte - startByte;
return;
@@ -131,7 +130,7 @@ void TStringRemoveRange(int startIndex, int count, TString* string) {
memcpy(&string->Characters[startByte], buffer, remainder);
}
memset(&string->Characters[endByte], '\0', string->ByteCount - endByte);
memset(&string->Characters[string->ByteCount - endByte - startByte], '\0', endByte - startByte);
string->Length -= glyphCount;
string->ByteCount -= endByte - startByte;