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

Commit

Permalink
[core] don't crash when the version number is not a number
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer committed Jul 20, 2016
1 parent a07fbe8 commit 03ebae0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mbgl/style/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/style_parser/version-not-number.info.json
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions test/fixtures/style_parser/version-not-number.style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"8"}

0 comments on commit 03ebae0

Please sign in to comment.