Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ CJSON_PUBLIC(void) cJSON_Delete(cJSON *item)
item->string = NULL;
}
global_hooks.deallocate(item);
item = NULL;
item = next;
}
}
Expand Down Expand Up @@ -380,6 +381,7 @@ static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_bu
{
/* free the temporary buffer */
input_buffer->hooks.deallocate(number_c_string);
number_c_string = NULL;
return false; /* parse_error */
}

Expand All @@ -404,6 +406,7 @@ static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_bu
input_buffer->offset += (size_t)(after_end - number_c_string);
/* free the temporary buffer */
input_buffer->hooks.deallocate(number_c_string);
number_c_string = NULL;
return true;
}

Expand Down Expand Up @@ -560,6 +563,7 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)

memcpy(newbuffer, p->buffer, p->offset + 1);
p->hooks.deallocate(p->buffer);
p->buffer = NULL;
}
p->length = newsize;
p->buffer = newbuffer;
Expand Down Expand Up @@ -2093,6 +2097,7 @@ static cJSON_bool add_item_to_object(cJSON * const object, const char * const st
if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
{
hooks->deallocate(item->string);
item->string = NULL;
}

item->string = new_key;
Expand Down