mirror of
https://github.com/taurusxin/ncmdump.git
synced 2025-07-13 12:52:20 +08:00
src/utils/cJSON.cpp: add NULL check in cJSON_InsertItemInArray
This commit is contained in:
parent
3fe1518325
commit
6c125d6152
@ -2142,7 +2142,7 @@ CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newit
|
|||||||
{
|
{
|
||||||
cJSON *after_inserted = NULL;
|
cJSON *after_inserted = NULL;
|
||||||
|
|
||||||
if (which < 0)
|
if (which < 0 || newitem == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2154,6 +2154,10 @@ CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (after_inserted != array->child && newitem->prev == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
newitem->next = after_inserted;
|
newitem->next = after_inserted;
|
||||||
newitem->prev = after_inserted->prev;
|
newitem->prev = after_inserted->prev;
|
||||||
after_inserted->prev = newitem;
|
after_inserted->prev = newitem;
|
||||||
|
Loading…
Reference in New Issue
Block a user