Skip to content

Commit bad85b3

Browse files
PushmePullyubluegr
authored andcommitted
SAGA: Fix use-after-free on handling actor action
On switching scenes: Reset _actor->_lastZone in Actor::updateActorsScene(). Actors can store a pointer to a HitZone in _lastZone (see Actor::handleActions()). The HitZone pointed to is held by ObjectMap vm->_scene->_objectMap in array _hitZoneList. When changing scenes the array elements are cleared via ObjectMap::clear() and _lastZone can become stale since only some code paths reset it (e.g. Actor::takeExit()). The stale pointer is then passed to Actor::stepZoneAction() from Actor::handleActions() and dereferenced. Fixes #13661
1 parent 034df5c commit bad85b3

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

engines/saga/actor_walk.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ void Actor::updateActorsScene(int actorsEntrance) {
192192
_protagonist = nullptr;
193193

194194
for (ActorDataArray::iterator actor = _actors.begin(); actor != _actors.end(); ++actor) {
195+
actor->_lastZone = nullptr;
195196
actor->_inScene = false;
196197
actor->_spriteList.clear();
197198
if ((actor->_flags & (kProtagonist | kFollower)) || (actor->_index == 0)) {

0 commit comments

Comments
 (0)