Merge pull request #52 from npt-1707/fix_CVE-2023-50471
Some checks failed
CI / build_on_windows_msys2 (push) Has been cancelled
CI / build_on_windows_msvc (push) Has been cancelled
CI / build_on_linux_amd64 (push) Has been cancelled
CI / build_on_macos_amd64 (push) Has been cancelled
CI / build_on_macos_arm64 (push) Has been cancelled

Fix potential vulnerable cloned function
This commit is contained in:
TaurusXin 2025-06-04 10:01:34 +08:00 committed by GitHub
commit 80a607a8fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2142,7 +2142,7 @@ CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newit
{
cJSON *after_inserted = NULL;
if (which < 0)
if (which < 0 || newitem == NULL)
{
return;
}
@ -2154,6 +2154,10 @@ CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newit
return;
}
if (after_inserted != array->child && newitem->prev == NULL) {
return;
}
newitem->next = after_inserted;
newitem->prev = after_inserted->prev;
after_inserted->prev = newitem;