Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Port fix for "at" expression off-by-1 error #11375

Merged
merged 3 commits into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mapbox-gl-js
Submodule mapbox-gl-js updated 37 files
+7 −2 src/source/video_source.js
+6 −2 src/style-spec/expression/definitions/at.js
+14 −13 src/ui/bind_handlers.js
+9 −9 src/ui/handler/drag_pan.js
+4 −4 src/ui/handler/touch_zoom_rotate.js
+31 −0 src/util/dom.js
+2 −2 test/integration/expression-tests/at/basic/test.json
+89 −81 test/integration/lib/server.js
+1 −0 test/integration/package.json
+1 −1 test/integration/render-tests/basic-v9/z0/style.json
+1 −1 test/integration/render-tests/bright-v9/z0/style.json
+1 −1 test/integration/render-tests/mixed-zoom/z10-z11/style.json
+ test/integration/render-tests/real-world/bangkok/expected.png
+17 −0 test/integration/render-tests/real-world/bangkok/style.json
+ test/integration/render-tests/real-world/chicago/expected.png
+17 −0 test/integration/render-tests/real-world/chicago/style.json
+ test/integration/render-tests/real-world/nepal/expected.png
+17 −0 test/integration/render-tests/real-world/nepal/style.json
+ test/integration/render-tests/real-world/norway/expected.png
+17 −0 test/integration/render-tests/real-world/norway/style.json
+ test/integration/render-tests/real-world/sanfrancisco/expected.png
+17 −0 test/integration/render-tests/real-world/sanfrancisco/style.json
+ test/integration/render-tests/real-world/uruguay/expected.png
+17 −0 test/integration/render-tests/real-world/uruguay/style.json
+1 −1 test/integration/render-tests/satellite-v9/z0/style.json
+976 −0 test/integration/styles/bangkok.json
+867 −0 test/integration/styles/chicago.json
+981 −0 test/integration/styles/nepal.json
+981 −0 test/integration/styles/norway.json
+981 −0 test/integration/styles/sanfrancisco.json
+981 −0 test/integration/styles/uruguay.json
+5 −0 test/integration/tilesets/mapbox.mapbox-streets-v7
+5 −0 test/integration/tilesets/mapbox.satellite
+1 −3 test/integration/tilesets/raster.json
+0 −1 test/integration/tilesets/vector.json
+4 −0 test/suite_implementation.js
+20 −1 yarn.lock
10 changes: 8 additions & 2 deletions src/mbgl/style/expression/at.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ EvaluationResult At::evaluate(const EvaluationContext& params) const {
const auto i = evaluatedIndex->get<double>();
const auto inputArray = evaluatedInput->get<std::vector<Value>>();

if (i < 0 || i >= inputArray.size()) {
if (i < 0) {
return EvaluationError {
"Array index out of bounds: " + stringify(i) + " < 0."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we're mixing stringify and util::toString?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, just an oversight, I think. Will consistentize before merging.

};
}

if (i >= inputArray.size()) {
return EvaluationError {
"Array index out of bounds: " + stringify(i) +
" > " + util::toString(inputArray.size()) + "."
" > " + util::toString(inputArray.size() - 1) + "."
};
}
if (i != std::floor(i)) {
Expand Down