Sync these patches from 24.03 branch: - Fix-a-null-pointer-crash-in-cJSON_ReplaceItemViaPoin.patch - backport-Add-test-for-heap-buffer-overflow.patch - backport-Fix-heap-buffer-overflow.patch - backport-fix-add-allocate-check-for-replace_item_in_object-67.patch - backport-fix-print-int-without-decimal-places-630.patch - backport-Set-free-d-pointers-to-NULL-whenever-they-are-not-re.patch Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
26 lines
837 B
Diff
26 lines
837 B
Diff
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
|
|
|