From d4ed8d1a4474e43241e42610001403261353466f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 23 Jan 2018 12:58:09 -0800 Subject: [core] fix style parsing crash when a layer's paint property is not an object --- src/mbgl/style/conversion/layer.cpp | 3 +++ test/fixtures/style_parser/paint-nonobject.info.json | 7 +++++++ test/fixtures/style_parser/paint-nonobject.style.json | 8 ++++++++ 3 files changed, 18 insertions(+) create mode 100644 test/fixtures/style_parser/paint-nonobject.info.json create mode 100644 test/fixtures/style_parser/paint-nonobject.style.json diff --git a/src/mbgl/style/conversion/layer.cpp b/src/mbgl/style/conversion/layer.cpp index 8f624e3324..ad6998341d 100644 --- a/src/mbgl/style/conversion/layer.cpp +++ b/src/mbgl/style/conversion/layer.cpp @@ -38,6 +38,9 @@ optional setPaintProperties(Layer& layer, const Convertible& value) { if (!paintValue) { return {}; } + if (!isObject(*paintValue)) { + return { { "paint must be an object" } }; + } return eachMember(*paintValue, [&] (const std::string& k, const Convertible& 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 + }] +} -- cgit v1.2.1