]> git.feebdaed.xyz Git - 0xmirror/cJSON.git/commitdiff
Check for NULL in cJSON_DetachItemViaPointer
authorNicolas Badoux <n.badoux@hotmail.com>
Fri, 23 Aug 2024 14:14:10 +0000 (14:14 +0000)
committerAlan Wang <wp_scut@163.com>
Fri, 30 Aug 2024 03:29:05 +0000 (11:29 +0800)
cJSON.c

diff --git a/cJSON.c b/cJSON.c
index cac1164b8c405b194abdd8ff7a1708f028b1bc93..483d0c0cd8c0a344fb23c43626e9803b3f7a2a5b 100644 (file)
--- a/cJSON.c
+++ b/cJSON.c
@@ -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;
     }