mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Handle array exceed limit potential crash
This commit is contained in:
@@ -302,7 +302,10 @@ CScenarioTravel CCampaignHandler::readScenarioTravelFromJson(JsonNode & reader,
|
|||||||
if(auto identifier = VLC->modh->identifiers.getIdentifier(CModHandler::scopeMap(), "creature", k.String()))
|
if(auto identifier = VLC->modh->identifiers.getIdentifier(CModHandler::scopeMap(), "creature", k.String()))
|
||||||
{
|
{
|
||||||
int creId = identifier.get();
|
int creId = identifier.get();
|
||||||
ret.monstersKeptByHero[creId / 8] |= (1 << creId % 8);
|
if(creId >= ret.monstersKeptByHero.size())
|
||||||
|
logGlobal->warn("VCMP Loading: creature %s with id %d isn't supported yet", k.String(), creId);
|
||||||
|
else
|
||||||
|
ret.monstersKeptByHero[creId / 8] |= (1 << creId % 8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
logGlobal->warn("VCMP Loading: keepCreatures contains unresolved identifier %s", k.String());
|
logGlobal->warn("VCMP Loading: keepCreatures contains unresolved identifier %s", k.String());
|
||||||
@@ -312,7 +315,10 @@ CScenarioTravel CCampaignHandler::readScenarioTravelFromJson(JsonNode & reader,
|
|||||||
if(auto identifier = VLC->modh->identifiers.getIdentifier(CModHandler::scopeMap(), "artifact", k.String()))
|
if(auto identifier = VLC->modh->identifiers.getIdentifier(CModHandler::scopeMap(), "artifact", k.String()))
|
||||||
{
|
{
|
||||||
int artId = identifier.get();
|
int artId = identifier.get();
|
||||||
ret.artifsKeptByHero[artId / 8] |= (1 << artId % 8);
|
if(artId >= ret.artifsKeptByHero.size())
|
||||||
|
logGlobal->warn("VCMP Loading: artifact %s with id %d isn't supported yet", k.String(), artId);
|
||||||
|
else
|
||||||
|
ret.artifsKeptByHero[artId / 8] |= (1 << artId % 8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
logGlobal->warn("VCMP Loading: keepArtifacts contains unresolved identifier %s", k.String());
|
logGlobal->warn("VCMP Loading: keepArtifacts contains unresolved identifier %s", k.String());
|
||||||
|
Reference in New Issue
Block a user