diff --git a/cJSON.c b/cJSON.c index 2c3f9e6..1e9802a 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1854,6 +1854,11 @@ CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) { + if ((object == NULL) || (string == NULL)) + { + return; + } + cJSON_AddItemToObject(object, string, create_reference(item, &global_hooks)); }