Fix StringBuf.add()

This commit is contained in:
Exzap 2023-03-12 10:59:20 +01:00
parent 504e0488a8
commit 9fb8f4cb6b

View File

@ -46,10 +46,11 @@ public:
{
size_t remainingLen = this->limit - this->length;
size_t copyLen = appendedStr.size();
if (remainingLen > copyLen)
if (remainingLen < copyLen)
copyLen = remainingLen;
char* outputStart = (char*)(this->str + this->length);
std::copy(appendedStr.data(), appendedStr.data() + copyLen, outputStart);
length += copyLen;
outputStart[copyLen] = '\0';
}