summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMolly Lloyd <mollymerp@users.noreply.github.com>2018-09-18 17:31:44 -0700
committerGitHub <noreply@github.com>2018-09-18 17:31:44 -0700
commit80bdbebdfebe0f3291a73ccefc5c5956640533e3 (patch)
treeb74f7099df8e494404182db29de8c6ae06d9251f
parenta938c3ef68af249bb3199bde2818436a0bff0952 (diff)
downloadqtlocation-mapboxgl-80bdbebdfebe0f3291a73ccefc5c5956640533e3.tar.gz
[core] prevent crash when expression for pattern evaluates to "" (#12896)
when a source-expression like `["get", "property"]` evaluates to null and the default pattern value (empty string) is used, make sure attribute buffers get populated to avoid crashing the app
m---------mapbox-gl-js0
-rw-r--r--src/mbgl/renderer/paint_property_binder.hpp13
2 files changed, 11 insertions, 2 deletions
diff --git a/mapbox-gl-js b/mapbox-gl-js
-Subproject f66cead4b8f95c696d7d2636f36cafaf4a4c6bc
+Subproject d38ade8f156d923da58b68923e56266d07f2d1a
diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp
index 391ecbb174..31abec68a9 100644
--- a/src/mbgl/renderer/paint_property_binder.hpp
+++ b/src/mbgl/renderer/paint_property_binder.hpp
@@ -302,8 +302,17 @@ public:
};
void populateVertexVector(const GeometryTileFeature&, std::size_t length, const ImagePositions& patternPositions, const optional<PatternDependency>& patternDependencies) override {
- if (!patternDependencies) return;
- if (!patternPositions.empty()) {
+
+ if (patternDependencies->mid.empty()) {
+ // Unlike other propperties with expressions that evaluate to null, the default value for `*-pattern` properties is an empty
+ // string and will not have a valid entry in patternPositions. We still need to populate the attribute buffers to avoid crashes
+ // when we try to draw the layer because we don't know at draw time if all features were evaluated to valid pattern dependencies.
+ for (std::size_t i = zoomInVertexVector.vertexSize(); i < length; ++i) {
+ patternToVertexVector.emplace_back(Vertex { std::array<uint16_t, 4>{{0, 0, 0, 0}} });
+ zoomInVertexVector.emplace_back(Vertex2 { std::array<uint16_t, 4>{{0, 0, 0, 0}} } );
+ zoomOutVertexVector.emplace_back(Vertex2 { std::array<uint16_t, 4>{{0, 0, 0, 0}} });
+ }
+ } else if (!patternPositions.empty()) {
const auto min = patternPositions.find(patternDependencies->min);
const auto mid = patternPositions.find(patternDependencies->mid);
const auto max = patternPositions.find(patternDependencies->max);