mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Fix potential access to destroyed variable on stack
This commit is contained in:
parent
0058c9ba2e
commit
76e3ca4afe
@ -45,11 +45,12 @@ void DamageCache::buildObstacleDamageCache(std::shared_ptr<HypotheticBattle> hb,
|
||||
continue;
|
||||
|
||||
std::unique_ptr<spells::BattleCast> cast = nullptr;
|
||||
std::unique_ptr<spells::ObstacleCasterProxy> caster = nullptr;
|
||||
if(spellObstacle->obstacleType == SpellCreatedObstacle::EObstacleType::SPELL_CREATED)
|
||||
{
|
||||
const auto * hero = hb->battleGetFightingHero(spellObstacle->casterSide);
|
||||
auto caster = spells::ObstacleCasterProxy(hb->getSidePlayer(spellObstacle->casterSide), hero, *spellObstacle);
|
||||
cast = std::make_unique<spells::BattleCast>(spells::BattleCast(hb.get(), &caster, spells::Mode::PASSIVE, obst->getTrigger().toSpell()));
|
||||
caster = std::make_unique<spells::ObstacleCasterProxy>(hb->getSidePlayer(spellObstacle->casterSide), hero, *spellObstacle);
|
||||
cast = std::make_unique<spells::BattleCast>(spells::BattleCast(hb.get(), caster.get(), spells::Mode::PASSIVE, obst->getTrigger().toSpell()));
|
||||
}
|
||||
|
||||
auto affectedHexes = obst->getAffectedTiles();
|
||||
|
Loading…
x
Reference in New Issue
Block a user