Skip to content

Commit

Permalink
Update cJSON.c
Browse files Browse the repository at this point in the history
added null check
  • Loading branch information
ste-lam authored Sep 15, 2024
1 parent 83779b2 commit 7e20932
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7e20932

Please sign in to comment.