From 06162800eebba59a6fa87d7d05f29fee0423f4e6 Mon Sep 17 00:00:00 2001 From: youbing54 Date: Fri, 20 Dec 2024 20:18:39 +0800 Subject: [PATCH] =?UTF-8?q?IssueNo:=20https://gitee.com/openharmony/third?= =?UTF-8?q?=5Fparty=5FcJSON/issues/IBCR1D=20describe:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=BC=8F=E6=B4=9ECVE-2024-31755=20Feature=20or=20Bugfix:=20Bug?= =?UTF-8?q?fix=20Binary=20Source:Yes=20Signed-off-by:=20youbing54?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cJSON.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index 63fb043..291f2ea 100644 --- a/cJSON.c +++ b/cJSON.c @@ -567,10 +567,16 @@ CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring) return NULL; } /* return NULL if the object is corrupted */ - if (object->valuestring == NULL || valuestring == NULL) + if (object->valuestring == NULL) { return NULL; } + if (valuestring == NULL) + { + cJSON_free(object->valuestring); + object->valuestring = NULL; + return NULL; + } if (strlen(valuestring) <= strlen(object->valuestring)) { strcpy(object->valuestring, valuestring); -- Gitee