Check for NULL in cJSON_DetachItemViaPointer

This commit is contained in:
Nicolas Badoux 2024-08-23 14:14:10 +00:00 committed by Alan Wang
parent 424ce4ce96
commit f28a468e3b

View File

@ -2204,7 +2204,7 @@ CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * c
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item)
{
if ((parent == NULL) || (item == NULL))
if ((parent == NULL) || (parent->child == NULL) || (item == NULL) || (item->prev == NULL))
{
return NULL;
}