1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

fix: time-of-check-to-time-of-use (TOCTOU) race condition in AIMemory::removeInvisibleObjects; a bit of refactoring in RecruitHeroBehavior and some todo comments for later on

This commit is contained in:
Mircea TheHonestCTO
2025-09-25 17:09:42 +02:00
parent 46668f7b23
commit a836cd3aed
18 changed files with 153 additions and 114 deletions

View File

@@ -94,8 +94,9 @@ void ObjectGraph::removeObject(const CGObjectInstance * obj, CCallback & cc)
void ObjectGraph::connectHeroes(const Nullkiller * aiNk)
{
for(auto obj : aiNk->memory->visitableObjs)
for(const ObjectInstanceID objId : aiNk->memory->visitableObjs)
{
const CGObjectInstance * obj = aiNk->cc->getObj(objId, false);
if(obj && obj->ID == Obj::HERO)
{
addObject(obj);