From 071f8ab6339db5a487ca0ca2079052f554190cf1 Mon Sep 17 00:00:00 2001 From: ZhaoYandong00 Date: Wed, 15 Nov 2023 15:16:24 +0800 Subject: [PATCH] Update cJSON.c fix strlen(NULL) --- cJSON.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index f6dd11c5..f2204384 100644 --- a/cJSON.c +++ b/cJSON.c @@ -405,7 +405,7 @@ CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring) { return NULL; } - if (strlen(valuestring) <= strlen(object->valuestring)) + if (object->valuestring && (strlen(valuestring) <= strlen(object->valuestring))) { strcpy(object->valuestring, valuestring); return object->valuestring;