From 7e20932700c9b8e5862f0d6dba045d274f7bf978 Mon Sep 17 00:00:00 2001 From: Steven <819106+ste-lam@users.noreply.github.com> Date: Sun, 15 Sep 2024 08:10:00 +0200 Subject: [PATCH] Update cJSON.c added null check --- cJSON.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index 91507e61..3ba64e0e 100644 --- a/cJSON.c +++ b/cJSON.c @@ -200,7 +200,10 @@ static char* cJSON_strndup(const char* string, const size_t length, const intern { return NULL; } - memcpy(copy, string, length); + if (string != NULL) + { + memcpy(copy, string, length); + } copy[length] = '\0'; return copy;