ensure: only memcopy what's necessary

We don't need to copy the entire printbuffer, only the part that is
used.
This commit is contained in:
Max Bruckner 2017-02-18 11:58:24 +01:00
parent 4fff92140e
commit 331c18d09a
1 changed files with 1 additions and 1 deletions

View File

@ -300,7 +300,7 @@ static unsigned char* ensure(printbuffer *p, size_t needed)
}
if (newbuffer)
{
memcpy(newbuffer, p->buffer, p->length);
memcpy(newbuffer, p->buffer, p->offset + 1);
}
cJSON_free(p->buffer);
}