mirror of
https://github.com/DaveGamble/cJSON.git
synced 2025-01-14 11:40:17 +08:00
handle null pointers: cJSON_AddItemToObject
This commit is contained in:
parent
2a3a313f83
commit
cdc35ebf88
5
cJSON.c
5
cJSON.c
@ -1790,6 +1790,11 @@ CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item)
|
|||||||
|
|
||||||
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
|
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
|
||||||
{
|
{
|
||||||
|
if (item == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* call cJSON_AddItemToObjectCS for code reuse */
|
/* call cJSON_AddItemToObjectCS for code reuse */
|
||||||
cJSON_AddItemToObjectCS(object, (char*)cJSON_strdup((const unsigned char*)string, &global_hooks), item);
|
cJSON_AddItemToObjectCS(object, (char*)cJSON_strdup((const unsigned char*)string, &global_hooks), item);
|
||||||
/* remove cJSON_StringIsConst flag */
|
/* remove cJSON_StringIsConst flag */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user