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

View File

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