mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 20:56:13 +00:00
Add return value checks for cJSON library (#1153)
This commit is contained in:
parent
2bac6a42a7
commit
21e59d883f
36
test-tools/host-tool/external/cJSON/cJSON.c
vendored
36
test-tools/host-tool/external/cJSON/cJSON.c
vendored
|
@ -1818,9 +1818,9 @@ add_item_to_array(cJSON *array, cJSON *item)
|
|||
}
|
||||
|
||||
/* Add item to array/object. */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item)
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item)
|
||||
{
|
||||
add_item_to_array(array, item);
|
||||
return add_item_to_array(array, item);
|
||||
}
|
||||
|
||||
#if defined(__clang__) \
|
||||
|
@ -1878,37 +1878,39 @@ add_item_to_object(cJSON *const object, const char *const string,
|
|||
return add_item_to_array(object, item);
|
||||
}
|
||||
|
||||
CJSON_PUBLIC(void)
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
|
||||
{
|
||||
add_item_to_object(object, string, item, &global_hooks, false);
|
||||
return add_item_to_object(object, string, item, &global_hooks, false);
|
||||
}
|
||||
|
||||
/* Add an item to an object with constant string as key */
|
||||
CJSON_PUBLIC(void)
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
|
||||
{
|
||||
add_item_to_object(object, string, item, &global_hooks, true);
|
||||
return add_item_to_object(object, string, item, &global_hooks, true);
|
||||
}
|
||||
|
||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
|
||||
{
|
||||
if (array == NULL) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
add_item_to_array(array, create_reference(item, &global_hooks));
|
||||
return add_item_to_array(array, create_reference(item, &global_hooks));
|
||||
}
|
||||
|
||||
CJSON_PUBLIC(void)
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
|
||||
{
|
||||
if ((object == NULL) || (string == NULL)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
add_item_to_object(object, string, create_reference(item, &global_hooks),
|
||||
&global_hooks, false);
|
||||
return add_item_to_object(object, string,
|
||||
create_reference(item, &global_hooks),
|
||||
&global_hooks, false);
|
||||
}
|
||||
|
||||
CJSON_PUBLIC(cJSON *)
|
||||
|
@ -2093,19 +2095,18 @@ cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string)
|
|||
}
|
||||
|
||||
/* Replace array/object items with new ones. */
|
||||
CJSON_PUBLIC(void)
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
|
||||
{
|
||||
cJSON *after_inserted = NULL;
|
||||
|
||||
if (which < 0) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
after_inserted = get_array_item(array, (size_t)which);
|
||||
if (after_inserted == NULL) {
|
||||
add_item_to_array(array, newitem);
|
||||
return;
|
||||
return add_item_to_array(array, newitem);
|
||||
}
|
||||
|
||||
newitem->next = after_inserted;
|
||||
|
@ -2117,6 +2118,7 @@ cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
|
|||
else {
|
||||
newitem->prev->next = newitem;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
|
|
13
test-tools/host-tool/external/cJSON/cJSON.h
vendored
13
test-tools/host-tool/external/cJSON/cJSON.h
vendored
|
@ -247,20 +247,21 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
|||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(void)
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
/* Use this when string is definitely const (i.e. a literal, or as good as), and
|
||||
* will definitely survive the cJSON object. WARNING: When this function was
|
||||
* used, make sure to always check that (item->type & cJSON_StringIsConst) is
|
||||
* zero before writing to `item->string` */
|
||||
CJSON_PUBLIC(void)
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||
/* Append reference to item to the specified array/object. Use this when you
|
||||
* want to add an existing cJSON to a new cJSON, but don't want to corrupt your
|
||||
* existing cJSON. */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(void)
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
|
||||
/* Remove/Detatch items from Arrays/Objects. */
|
||||
|
@ -278,7 +279,7 @@ CJSON_PUBLIC(void)
|
|||
cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
CJSON_PUBLIC(void)
|
||||
CJSON_PUBLIC(cJSON_bool)
|
||||
cJSON_InsertItemInArray(
|
||||
cJSON *array, int which,
|
||||
cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
|
|
Loading…
Reference in New Issue
Block a user