When building using a newer Clang with additional diagnostics
the following warnings are given:
-Wunused-but-set-variable
-Wstrict-prototypes
These issues are corrected in this commit.
Reproducable using:
CC="clang-13" CFLAGS="-Wall -pedantic" cmake ..
A couple of testcases did not free its `match_entry` allocations,
which triggers leak indications.
Visible when build and run using the leak sanitizer, i.e
`CFLAGS="-fno-omit-frame-pointer -fsanitize=leak" cmake ..`
Adds a testcase for the usage of the access macros, and also
updates the testsuite to only include what str_array requires.
This shows that str_array can be used separately by users.
When inserting multiple routes with common slug patterns
there are reads beyond end of strings.
The scenario is added as a testcase and can be triggered by
the address-sanitizer when built using:
`CFLAGS="-fno-omit-frame-pointer -fsanitize=address" cmake ..`
Indicated as a `buffer-overflow`
When `r3_node_find_common_prefix()` searches for the common prefix it
selects the first matched edge, which might not be the best match.
This issue gives memoryleaks which can be viewed in legacy
testcase `check_tree::test_insert_pathl()` by building using:
`CFLAGS="-fno-omit-frame-pointer -fsanitize=leak" cmake ..`
See testcase procedures:
ret = r3_tree_insert_path(n, "/foo/{id}", NULL);
..
ret = r3_tree_insert_path(n, "/foo/{idx}/{idy}", NULL);
..
ret = r3_tree_insert_path(n, "/foo/{idx}/{idh}", NULL); <-- leaks
Also added a testcase that triggers the problem including a leak for
reproduction on baseline.
This patch fixes a few issues in the check_tree test:
* Fix various memory leaks in test code
* Fix a double-free in test code
* Fix a memory leak in r3_tree_compile_patterns
One memory leak remains in the library code but it isn't obvious to me
how to fix it at the moment.