diff --git a/cJSON.c b/cJSON.c index 4b5005a..89943b5 100644 --- a/cJSON.c +++ b/cJSON.c @@ -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); }