* fix: correct operator precedence in ForAllFields reverse iteration
The expression `size() - i + 1` evaluates as `(size() - i) + 1` due to
left-to-right associativity, producing an out-of-bounds index when
reverse=true. For a vector of size N, the first iteration (i=0) accesses
index N+1, which is 2 past the last valid index.
Changed to `size() - (i + 1)` to match the correct implementation
already present in bfbs_gen.h:192.
Bug: CWE-125 (Out-of-bounds Read), CWE-783 (Operator Precedence Error)
* test: add ForAllFieldsReverseTest for reverse iteration correctness
Verify that ForAllFields with reverse=true iterates fields in
descending ID order. Tests both Stat (3 fields) and Monster
(many fields with non-sequential definition order) tables.
---------
Co-authored-by: Tulgaa <tulgaa.kek@gmail.com>
Without the change build fails on weekly `gcc-13` snapshots as:
In file included from /build/flatbuffers/tests/reflection_test.cpp:1:
tests/reflection_test.h:9:57: error: 'uint8_t' has not been declared
9 | void ReflectionTest(const std::string& tests_data_path, uint8_t *flatbuf, size_t length);
| ^~~~~~~
* Add timing command to cmakelist
* Start to split test.cpp. Move flexbuffers tests
* Move monster related tests to own file
* Move parser related tests to own file
* Move json related tests to own file
* Move proto related tests to own file
* moved more functions to parser test
* moved more functions to parser test2
* move monster extra tests to monster test
* move evolution tests to own file
* move reflection tests to own file
* move util tests to own file
* rehomed various tests
* move optional scalars test to own file:
* rehome more tests
* move fuzz tests. Got rid of global test_data_path
* fixes for CI failures
* add bazel files