mirror of
https://github.com/json-c/json-c.git
synced 2026-04-13 17:29:06 +08:00
@@ -430,13 +430,14 @@ int json_pointer_set_with_limit_index(struct json_object **obj, const char *path
|
|||||||
int json_object_array_put_idx_with_limit_cb(struct json_object *jso, size_t idx,
|
int json_object_array_put_idx_with_limit_cb(struct json_object *jso, size_t idx,
|
||||||
struct json_object *jso_new, void *priv)
|
struct json_object *jso_new, void *priv)
|
||||||
{
|
{
|
||||||
|
size_t max_idx;
|
||||||
// use priv as a size_t pointer to pass in the maximum allowed index
|
// use priv as a size_t pointer to pass in the maximum allowed index
|
||||||
if (!priv)
|
if (!priv)
|
||||||
{
|
{
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
size_t max_idx = *(size_t*)priv;
|
max_idx = *(size_t*)priv;
|
||||||
|
|
||||||
// Check against a maximum to prevent excessive memory allocations.
|
// Check against a maximum to prevent excessive memory allocations.
|
||||||
// An extremely large index, even if it doesn't overflow size_t,
|
// An extremely large index, even if it doesn't overflow size_t,
|
||||||
|
|||||||
Reference in New Issue
Block a user