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;