[core] don't crash when the version number is not a number
This commit is contained in:
@@ -35,7 +35,8 @@ void Parser::parse(const std::string& json) {
|
||||
}
|
||||
|
||||
if (document.HasMember("version")) {
|
||||
int version = document["version"].GetInt();
|
||||
const JSValue& versionValue = document["version"];
|
||||
const int version = versionValue.IsNumber() ? versionValue.GetInt() : 0;
|
||||
if (version != 8) {
|
||||
Log::Warning(Event::ParseStyle, "current renderer implementation only supports style spec version 8; using an outdated style will cause rendering errors");
|
||||
}
|
||||
|
||||
7
test/fixtures/style_parser/version-not-number.info.json
vendored
Normal file
7
test/fixtures/style_parser/version-not-number.info.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"default": {
|
||||
"log": [
|
||||
[1, "WARNING", "ParseStyle", "current renderer implementation only supports style spec version 8; using an outdated style will cause rendering errors"]
|
||||
]
|
||||
}
|
||||
}
|
||||
1
test/fixtures/style_parser/version-not-number.style.json
vendored
Normal file
1
test/fixtures/style_parser/version-not-number.style.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":"8"}
|
||||
Reference in New Issue
Block a user