summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-01-23 13:03:57 -0800
committerKonstantin Käfer <mail@kkaefer.com>2018-01-23 13:56:42 -0800
commit3f7c30f9d3716bcf1ebea617a38aebe1401e20a1 (patch)
tree07ec32304d560074904873561eaf8d02812251dc
parent14f3f86f6347c5d4ec2d9fe9d0ca8b05e6b06932 (diff)
downloadqtlocation-mapboxgl-3f7c30f9d3716bcf1ebea617a38aebe1401e20a1.tar.gz
[core] fix style parsing crash when a layer's paint property is not an object
-rw-r--r--include/mbgl/style/conversion/layer.hpp3
-rw-r--r--test/fixtures/style_parser/paint-nonobject.info.json7
-rw-r--r--test/fixtures/style_parser/paint-nonobject.style.json8
3 files changed, 18 insertions, 0 deletions
diff --git a/include/mbgl/style/conversion/layer.hpp b/include/mbgl/style/conversion/layer.hpp
index 1fe467165d..c694c3162a 100644
--- a/include/mbgl/style/conversion/layer.hpp
+++ b/include/mbgl/style/conversion/layer.hpp
@@ -43,6 +43,9 @@ optional<Error> setPaintProperties(Layer& layer, const V& value) {
if (!paintValue) {
return {};
}
+ if (!isObject(*paintValue)) {
+ return { { "paint must be an object" } };
+ }
return eachMember(*paintValue, [&] (const std::string& k, const V& v) {
return setPaintProperty(layer, k, v);
});
diff --git a/test/fixtures/style_parser/paint-nonobject.info.json b/test/fixtures/style_parser/paint-nonobject.info.json
new file mode 100644
index 0000000000..c9ae97efd8
--- /dev/null
+++ b/test/fixtures/style_parser/paint-nonobject.info.json
@@ -0,0 +1,7 @@
+{
+ "default": {
+ "log": [
+ [1, "WARNING", "ParseStyle", "paint must be an object"]
+ ]
+ }
+}
diff --git a/test/fixtures/style_parser/paint-nonobject.style.json b/test/fixtures/style_parser/paint-nonobject.style.json
new file mode 100644
index 0000000000..24ec89eda5
--- /dev/null
+++ b/test/fixtures/style_parser/paint-nonobject.style.json
@@ -0,0 +1,8 @@
+{
+ "version": 8,
+ "layers": [{
+ "id": "background",
+ "type": "background",
+ "paint": true
+ }]
+}