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

Fix style parsing crash when a layer's paint property is not an object #11001

Merged
merged 1 commit into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}]
}