1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix potential access violation due to iterator invalidation

This commit is contained in:
Ivan Savenko 2022-12-29 14:28:38 +02:00
parent da7766e90b
commit 7a5258853a

View File

@ -348,7 +348,11 @@ void BattleStacksController::update()
void BattleStacksController::updateBattleAnimations()
{
for (auto & elem : currentAnimations)
// operate on copy - to prevent potential iterator invalidation due to push_back's
// FIXME? : remove remaining calls to addNewAnim from BattleAnimation::nextFrame (only Catapult explosion at the time of writing)
auto copiedVector = currentAnimations;
for (auto & elem : copiedVector)
{
if (!elem)
continue;