[core] fix crash when the style JSON doesn't have an object at its root
This commit is contained in:
@@ -29,6 +29,11 @@ void Parser::parse(const std::string& json) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!document.IsObject()) {
|
||||
Log::Error(Event::ParseStyle, "Style JSON must be an object");
|
||||
return;
|
||||
}
|
||||
|
||||
if (document.HasMember("version")) {
|
||||
int version = document["version"].GetInt();
|
||||
if (version != 8) {
|
||||
|
||||
7
test/fixtures/style_parser/non-object.info.json
vendored
Normal file
7
test/fixtures/style_parser/non-object.info.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"default": {
|
||||
"log": [
|
||||
[1, "ERROR", "ParseStyle", "Style JSON must be an object"]
|
||||
]
|
||||
}
|
||||
}
|
||||
1
test/fixtures/style_parser/non-object.style.json
vendored
Normal file
1
test/fixtures/style_parser/non-object.style.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
""
|
||||
Reference in New Issue
Block a user