cjson/Fix-a-null-pointer-crash-in-cJSON_ReplaceItemViaPoin.patch

26 lines
837 B
Diff
Raw Permalink Normal View History

From 73d8cbbaf1c8b5ceb5a46a8e7d9a24aa3edaf0a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=82=96=E5=9C=A8?= <xiaozai@kylinos.cn>
Date: Tue, 7 May 2024 11:40:54 +0800
Subject: [PATCH] Fix a null pointer crash in cJSON_ReplaceItemViaPointer
---
cJSON.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cJSON.c b/cJSON.c
index 349ebbd..a1073ed 100644
--- a/cJSON.c
+++ b/cJSON.c
@@ -2304,7 +2304,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement)
{
- if ((parent == NULL) || (replacement == NULL) || (item == NULL))
+ if ((parent == NULL) || (parent->child == NULL) || (replacement == NULL) || (item == NULL))
{
return false;
}
--
2.33.0