Fixture tester should not access invalid array entries
@flippmoke is already working on this.
Since Apr 22, 2018.
- Dominant language
- C++
- Stars
- 197
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
The fixture tester is not careful to check that the coordinate arrays it is parsing in this loop: https://github.com/mapbox/wagyu/blob/c1efc210f215ccb88b3fe3774063dd249dc88e91/tests/fixture-tester.cpp#L105-L107 have both X and Y values. This means that an invalid JSON file like:
```json
[
[
[-2500],
[-2500.20], [-25250000,-2,-2500],
[-2500.2500],
[250062500],
[2500,-2560],[-2500,-2500] ]
]
```
Will result in bogus values in release mode like:
```
-2500 0
1717986918 0
-25250000 -2
0 250062500
250062500 2500
2500 -2560
-2500 -2500
```
^^ generated by doing:
```diff
diff --git a/tests/fixture-tester.cpp b/tests/fixture-tester.cpp
index 02036d7..b1dde95 100644
--- a/tests/fixture-tester.cpp
+++ b/tests/fixture-tester.cpp
@@ -103,6 +103,7 @@ mapbox::geometry::polygon parse_file(const char* file_path) {
") is not a valid json array");
}
for (SizeType j = 0; j < document[i].Size(); ++j) {
+ std::clog << document[i][j][0].GetInt() << " " << document[i][j][1].GetInt() << "\n";
lr.push_back({ document[i][j][0].GetInt(), document[i][j][1].GetInt() });
}
poly.emplace_back(lr);
```
And in debug mode rapidjson catches the problem:
```
Assertion failed: (index < data_.a.size), function operator[], file mason_packages/headers/rapidjson/1.1.0/include/rapidjson/document.h, line 1498.
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.