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

Commit

Permalink
[core] fix style parsing crash when a layer's paint property is not a…
Browse files Browse the repository at this point in the history
…n object
  • Loading branch information
kkaefer committed Jan 23, 2018
1 parent f329420 commit d4ed8d1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mbgl/style/conversion/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ optional<Error> 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);
});
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/style_parser/paint-nonobject.info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"default": {
"log": [
[1, "WARNING", "ParseStyle", "paint must be an object"]
]
}
}
8 changes: 8 additions & 0 deletions test/fixtures/style_parser/paint-nonobject.style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 8,
"layers": [{
"id": "background",
"type": "background",
"paint": true
}]
}

0 comments on commit d4ed8d1

Please sign in to comment.