Added a test that appends a string longer that the capacity of the builder

This commit is contained in:
Benoît Blanchon
2014-06-26 13:00:14 +02:00
parent ca99749f28
commit 7ab728e996
3 changed files with 15 additions and 6 deletions

View File

@ -10,9 +10,12 @@ void StringBuilder::append(const char* s)
{
char* tail = buffer + length;
strncpy(tail, s, capacity - length);
while (*s && length<capacity)
{
buffer[length++] = *s++;
}
length += strlen(tail);
buffer[length] = 0;
}
void StringBuilder::appendEscaped(const char* s)
@ -24,7 +27,7 @@ void StringBuilder::appendEscaped(const char* s)
// keep one slot for the end quote
capacity--;
while (*s && length<capacity)
while (*s && length < capacity)
{
switch (*s)
{