diff options
author | Anand Thakker <anandthakker@users.noreply.github.com> | 2018-03-02 16:38:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-02 16:38:46 -0500 |
commit | 8ed540ea7b90d29e1d0947f9a421f36ab9bc66b2 (patch) | |
tree | 35067d64be57ba08b2a4ddf0afd636a8616c32ab /src | |
parent | 4919099ea9c7e5d2a0ed261b169c7c6a0e86a43f (diff) | |
download | qtlocation-mapboxgl-8ed540ea7b90d29e1d0947f9a421f36ab9bc66b2.tar.gz |
Port fix for "at" expression off-by-1 error (#11375)
* Port fix for "at" expression off-by-1 error
Refs https://github.com/mapbox/mapbox-gl-js/pull/6269
* Consistency
* Add ignores for symbol positiong differences in real-world tests
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/style/expression/at.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/mbgl/style/expression/at.cpp b/src/mbgl/style/expression/at.cpp index e447d33bc7..725e5ddb51 100644 --- a/src/mbgl/style/expression/at.cpp +++ b/src/mbgl/style/expression/at.cpp @@ -19,15 +19,21 @@ 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) + - " > " + util::toString(inputArray.size()) + "." + "Array index out of bounds: " + util::toString(i) + " < 0." + }; + } + + if (i >= inputArray.size()) { + return EvaluationError { + "Array index out of bounds: " + util::toString(i) + + " > " + util::toString(inputArray.size() - 1) + "." }; } if (i != std::floor(i)) { return EvaluationError { - "Array index must be an integer, but found " + stringify(i) + " instead." + "Array index must be an integer, but found " + util::toString(i) + " instead." }; } return inputArray[static_cast<std::size_t>(i)]; |