mirror of
https://github.com/DaveGamble/cJSON.git
synced 2024-12-27 14:14:07 +08:00
cJSON_strdup: Check for NULL string
This commit is contained in:
parent
ddadb44a67
commit
1df987a170
5
cJSON.c
5
cJSON.c
@ -88,6 +88,11 @@ static char* cJSON_strdup(const char* str)
|
|||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
char *copy = NULL;
|
char *copy = NULL;
|
||||||
|
|
||||||
|
if (str == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
len = strlen(str) + 1;
|
len = strlen(str) + 1;
|
||||||
if (!(copy = (char*)cJSON_malloc(len)))
|
if (!(copy = (char*)cJSON_malloc(len)))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user