diff --git a/tstring.c b/tstring.c index 20ccfd5..16d278a 100644 --- a/tstring.c +++ b/tstring.c @@ -74,10 +74,10 @@ void TStringPop(char buffer[8], TString* string) { if (!string) return; if (string->ByteCount == 0) return; - for (int i = string->ByteCount; i >= 0; i--) { + for (int i = string->ByteCount - 1; i >= 0; i--) { unsigned int width = GetGlyphByteWidth(string->Characters[i]); - if (width) { + if (width > 0) { //If we've been provided a buffer, then populate it with the glyph we're removing. if (buffer) { memset(buffer, '\0', 8); @@ -132,6 +132,8 @@ void TStringRemoveRange(int startIndex, int count, TString* string) { memcpy(&string->Characters[startByte], buffer, remainder); } + memset(&string->Characters[endByte], '\0', string->ByteCount - endByte); + string->Length -= glyphCount; string->ByteCount -= endByte - startByte; }