cjson/backport-fix-potential-memory-leak-in-merge_patch.patch
lvfei 7db90b260c fix CVE-2024-31755 and potential memory leak
(cherry picked from commit 12d09877f421df3de1c2104b7a5529d28d5663db)
2024-04-29 14:14:35 +08:00

13 lines
436 B
Diff

diff --git a/cJSON_Utils.c b/cJSON_Utils.c
index c7c6439..63651df 100644
--- a/cJSON_Utils.c
+++ b/cJSON_Utils.c
@@ -1367,6 +1367,7 @@ static cJSON *merge_patch(cJSON *target, const cJSON * const patch, const cJSON_
replacement = merge_patch(replace_me, patch_child, case_sensitive);
if (replacement == NULL)
{
+ cJSON_Delete(target);
return NULL;
}