mirror of
https://github.com/DaveGamble/cJSON.git
synced 2026-10-29 12:41:09 +00:00
Add NULL check to cJSON_SetValuestring()
If the valuestring passed to cJSON_SetValuestring is NULL, a null pointer dereference will happen. This commit adds the NULL check of valuestring before it is dereferenced.
This commit is contained in:
1 parent
87d8f0961a
commit
7e4d5dabe7
1 file changed
+1
-1
@@ -406,7 +406,7 @@ CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* return NULL if the object is corrupted */
|
/* return NULL if the object is corrupted */
|
||||||
if (object->valuestring == NULL)
|
if (object->valuestring == NULL || valuestring == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user