From f28a468e3b287d633fea5d4d5ab444bb9354b4bc Mon Sep 17 00:00:00 2001 From: Nicolas Badoux Date: Fri, 23 Aug 2024 14:14:10 +0000 Subject: [PATCH] Check for NULL in cJSON_DetachItemViaPointer --- cJSON.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index cac1164..483d0c0 100644 --- 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; }