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
16 changes: 15 additions & 1 deletion cJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -2139,12 +2139,26 @@ CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item

CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
{
cJSON *reference = NULL;

if ((object == NULL) || (string == NULL))
{
return false;
}

return add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false);
reference = create_reference(item, &global_hooks);
if (reference == NULL)
{
return false;
}

if (!add_item_to_object(object, string, reference, &global_hooks, false))
{
cJSON_Delete(reference);
return false;
}

return true;
}

CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name)
Expand Down