diff options
-rw-r--r-- | src/mbgl/style/parser.cpp | 3 | ||||
-rw-r--r-- | test/fixtures/style_parser/version-not-number.info.json | 7 | ||||
-rw-r--r-- | test/fixtures/style_parser/version-not-number.style.json | 1 |
3 files changed, 10 insertions, 1 deletions
diff --git a/src/mbgl/style/parser.cpp b/src/mbgl/style/parser.cpp index 56e6f8ad01..2746b8af92 100644 --- a/src/mbgl/style/parser.cpp +++ b/src/mbgl/style/parser.cpp @@ -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"); } diff --git a/test/fixtures/style_parser/version-not-number.info.json b/test/fixtures/style_parser/version-not-number.info.json new file mode 100644 index 0000000000..130c334170 --- /dev/null +++ b/test/fixtures/style_parser/version-not-number.info.json @@ -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"] + ] + } +}
\ No newline at end of file diff --git a/test/fixtures/style_parser/version-not-number.style.json b/test/fixtures/style_parser/version-not-number.style.json new file mode 100644 index 0000000000..ae3ef858a6 --- /dev/null +++ b/test/fixtures/style_parser/version-not-number.style.json @@ -0,0 +1 @@ +{"version":"8"}
\ No newline at end of file |