Преглед на файлове

print: fix: realloc was allocating too much memory

Thanks @liuyunbin for reporting this in #230
Max Bruckner преди 7 години
родител
ревизия
28d4410f42
променени са 1 файла, в които са добавени 1 реда и са изтрити 1 реда
  1. 1 1
      cJSON.c

+ 1 - 1
cJSON.c

@@ -1113,7 +1113,7 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
     /* check if reallocate is available */
     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;
         if (printed == NULL) {
             goto fail;