reject empty reference token as array index in json_pointer

This commit is contained in:
Javid Khan
2026-07-20 14:44:51 +05:30
parent 1e39345938
commit 70f3169bae
3 changed files with 15 additions and 0 deletions
+6
View File
@@ -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
*/