15 Commits

Author SHA1 Message Date
Alexandru Ardelean
1c38dea651 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>
2023-07-31 22:17:30 -04:00
Tobias Stoeckmann
543a8eb5f9 Fix typos
Mostly found with codespell and during code review.
2022-03-06 16:07:36 +01:00
Eric Haszlakiewicz
6068d3f6d1 Change the strerror_override handling to check $_JSON_C_STRERROR_OVERRIDE instead of using a variable, so we don't need to export it. 2020-07-04 18:58:00 +00:00
David McCann
add7b13a9a Improved support for IBM operating systems
Fix compiler errors and warnings when building on IBM operating systems such as AIX and IBM i.
2020-05-14 15:39:35 +01:00
dota17
8b162c4b89 clang-format the files 2020-04-03 11:39:30 +08:00
dota17
c117d8a8a8 add the disabling formatting coments and adjust the partial code manuly 2020-04-03 11:28:04 +08:00
dota17
e56ab0146f update testcase and delete debug -O0 build 2020-03-02 20:19:35 +08:00
dota17
2d44f865c3 modify json-c default build type, and fix up the assert() errors in testcase 2020-02-29 15:32:42 +08:00
dota17
48ae9e8874 update pointer test case 2020-01-02 10:49:29 +08:00
Eric Haszlakiewicz
7f30afc6e5 Fix some Windows compile issues, add JSON_EXPORT's, fix bogus character escapes, define __func__ and omit unistd.h if needed. 2019-11-23 20:31:14 -05:00
Eric Haszlakiewicz
fcad0ec015 PR #336: since we can't use function overriding (due to problems with it on
OSX) always include the _json_c_strerror function but only enable it with a flag
 during tests.
2017-07-15 07:12:44 -07:00
Alexandru Ardelean
fb72160caf build: make strerror() override-able
If we want to override `strerror()` in libjson-c
to make tests consistent across platforms, we
need to do it build-wide as configure/build
option.

Apple linkers make it really hard to override functions
at link-time, and this seems to be locked down on travis-ci.org
[ for security reasons I assume ].
While I got it to work locally, it did not work
when running on travis.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2017-07-13 10:27:24 +03:00
Eric Haszlakiewicz
0a010a59eb Change a memcpy that should be a memmove within json_pointer_get, and fix memory leaks in of one the json_pointer tests. 2016-12-18 14:33:41 -05:00
Alexandru Ardelean
c0da680f13 test_json_pointer: update test with a few printf variants
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2016-11-22 16:37:18 +02:00
Alexandru Ardelean
ee7fc26de1 tests: add test_json_pointer test
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2016-11-04 09:59:43 +02:00