fix(Core/Movement): use-after-free using DontCacheRandomMovementPaths (#24935)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
sogladev
2026-03-04 06:06:43 +01:00
committed by GitHub
parent 2e8ba2e2d3
commit 82307e319e

View File

@@ -211,7 +211,8 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
}
_currentPoint = newPoint;
G3D::Vector3& finalPoint = finalPath[finalPath.size() - 1];
ASSERT(!finalPath.empty());
G3D::Vector3 finalPoint = finalPath.back();
_currDestPosition.Relocate(finalPoint.x, finalPoint.y, finalPoint.z);
creature->AddUnitState(UNIT_STATE_ROAMING_MOVE);
@@ -239,12 +240,13 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
_moveCount = 0;
_nextMoveTime.Reset(urand(4000, 8000));
}
if (sWorld->getBoolConfig(CONFIG_DONT_CACHE_RANDOM_MOVEMENT_PATHS))
_preComputedPaths.erase(pathIdx);
//Call for creature group update
if (creature->GetFormation() && creature->GetFormation()->GetLeader() == creature)
creature->GetFormation()->LeaderMoveTo(finalPoint.x, finalPoint.y, finalPoint.z, 0);
if (sWorld->getBoolConfig(CONFIG_DONT_CACHE_RANDOM_MOVEMENT_PATHS))
_preComputedPaths.erase(pathIdx);
}
template<>