Skip to content

Commit

Permalink
print: Fix default buffer size in printbuffer
Browse files Browse the repository at this point in the history
Thanks @liuyunbin for reporting this in DaveGamble#230
  • Loading branch information
FSMaxB committed Jan 9, 2018
1 parent 984dc85 commit f33fa95
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,13 +1087,15 @@ CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value)

static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks)
{
static const size_t default_buffer_size = 256;
printbuffer buffer[1];
unsigned char *printed = NULL;

memset(buffer, 0, sizeof(buffer));

/* create buffer */
buffer->buffer = (unsigned char*) hooks->allocate(256);
buffer->buffer = (unsigned char*) hooks->allocate(default_buffer_size);
buffer->length = default_buffer_size;
buffer->format = format;
buffer->hooks = *hooks;
if (buffer->buffer == NULL)
Expand Down

0 comments on commit f33fa95

Please sign in to comment.