提交 28d4410f 编写于 作者: M Max Bruckner

print: fix: realloc was allocating too much memory

Thanks @liuyunbin for reporting this in #230
上级 f33fa95f
...@@ -1113,7 +1113,7 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i ...@@ -1113,7 +1113,7 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
/* check if reallocate is available */ /* check if reallocate is available */
if (hooks->reallocate != NULL) if (hooks->reallocate != NULL)
{ {
printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->length); printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1);
buffer->buffer = NULL; buffer->buffer = NULL;
if (printed == NULL) { if (printed == NULL) {
goto fail; goto fail;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册