1
0
mirror of https://github.com/DaveGamble/cJSON synced 2025-04-18 13:06:29 +00:00
This commit is contained in:
Jerry 2024-09-23 15:21:43 -07:00 committed by GitHub
commit 389f17629b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2220,7 +2220,7 @@ CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const it
return NULL;
}
if (item != parent->child)
if (item != parent->child && item->prev != NULL)
{
/* not the first element */
item->prev->next = item->next;
@ -2236,7 +2236,7 @@ CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const it
/* first element */
parent->child = item->next;
}
else if (item->next == NULL)
else if (item->next == NULL && parent->child != NULL)
{
/* last element */
parent->child->prev = item->prev;