Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 766dd9d

Browse files
Fix a null pointer crash in cJSON_ReplaceItemViaPointer (DaveGamble#726)
If the parent passed in cJSON_ReplaceItemViaPointer has not a child, which means parent->child is null, a null pointer dereference crash will be happened inside cJSON_ReplaceItemViaPointer. This commit adds the NULL check of `parent->child` beforehand to inform user such incorrect usage. Signed-off-by: hopper-vul <hopper.vul@gmail.com>
1 parent b45f48e commit 766dd9d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎cJSON.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2291,7 +2291,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON
22912291

22922292
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement)
22932293
{
2294-
if ((parent == NULL) || (replacement == NULL) || (item == NULL))
2294+
if ((parent == NULL) || (parent->child==NULL) || (replacement == NULL) || (item == NULL))
22952295
{
22962296
return false;
22972297
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /