mirror of
https://github.com/json-c/json-c.git
synced 2026-09-08 00:56:50 +08:00
reject empty reference token as array index in json_pointer
This commit is contained in:
@@ -46,6 +46,12 @@ static void string_replace_all_occurrences_with_char(char *s, const char *occur,
|
||||
static int is_valid_index(const char *path, size_t *idx)
|
||||
{
|
||||
size_t i, len = strlen(path);
|
||||
/* an empty reference token is never a valid array index */
|
||||
if (len == 0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
/* this code-path optimizes a bit, for when we reference the 0-9 index range
|
||||
* in a JSON array and because leading zeros not allowed
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user