]> git.ipfire.org Git - thirdparty/json-c.git/commit
json_pointer: move array out-of-bounds check outside of is_valid_index()
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Fri, 23 Apr 2021 18:19:49 +0000 (21:19 +0300)
committerEric Hawicz <erh+git@nimenees.com>
Tue, 1 Aug 2023 02:17:30 +0000 (22:17 -0400)
commit1c38dea651447fcaf4ec5930d622a7d0e6384e43
treea8f7b3b745d787cfc40503e81e8da985243bcdcd
parent5a46a3b76d774ab3f2d884462d4bd4c382f3e835
json_pointer: move array out-of-bounds check outside of is_valid_index()

The out-of-bounds check is useful when trying to index/obtain a value from
an array.
However, when we set a value to a specific JSON pointer, we can allow
values that are outside the length of the current array.
The RFC6901 doc isn't clear on that aspect, and doing so is a bit more
in-line with how json_object_array_{put,insert}_idx() functions behave.

This changes the behavior of json_pointer_set{f}() because now a value can
be set anywhere in the array.

Also, added a test-case for this behavior change.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
json_pointer.c
tests/test_json_pointer.c