mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
fix crash in jsonschema in case of invalid typename
This commit is contained in:
parent
5ec750e0f5
commit
9f01a92f4c
@ -594,8 +594,15 @@ namespace
|
||||
}
|
||||
|
||||
std::string typeCheck(Validation::ValidationData & validator, const JsonNode & baseSchema, const JsonNode & schema, const JsonNode & data)
|
||||
{
|
||||
JsonNode::JsonType type = stringToType.find(schema.String())->second;
|
||||
{
|
||||
const auto typeName = schema.String();
|
||||
auto it = stringToType.find(typeName);
|
||||
if(it == stringToType.end())
|
||||
{
|
||||
return validator.makeErrorMessage("Unknown type in schema:" + typeName);
|
||||
}
|
||||
|
||||
JsonNode::JsonType type = it->second;
|
||||
if(type != data.getType() && data.getType() != JsonNode::DATA_NULL)
|
||||
return validator.makeErrorMessage("Type mismatch! Expected " + schema.String());
|
||||
return "";
|
||||
|
Loading…
Reference in New Issue
Block a user