cJSON_DetachItemViaPointer: added test and fix for check for null in item->prev

This commit is contained in:
Nicolas Badoux
2024-08-25 23:18:14 +02:00
committed by Alan Wang
parent f28a468e3b
commit a78d975537
2 changed files with 17 additions and 1 deletions

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) || (parent->child == NULL) || (item == NULL) || (item->prev == NULL))
if ((parent == NULL) || (item == NULL) || (item != parent->child && item->prev == NULL))
{
return NULL;
}