[core] fix style parsing crash when a layer's paint property is not an object
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
7
test/fixtures/style_parser/paint-nonobject.info.json
vendored
Normal file
7
test/fixtures/style_parser/paint-nonobject.info.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"default": {
|
||||
"log": [
|
||||
[1, "WARNING", "ParseStyle", "paint must be an object"]
|
||||
]
|
||||
}
|
||||
}
|
||||
8
test/fixtures/style_parser/paint-nonobject.style.json
vendored
Normal file
8
test/fixtures/style_parser/paint-nonobject.style.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"version": 8,
|
||||
"layers": [{
|
||||
"id": "background",
|
||||
"type": "background",
|
||||
"paint": true
|
||||
}]
|
||||
}
|
||||
Reference in New Issue
Block a user