Skip to content

Commit

Permalink
AGS: Add sanity check for frame in turning animation
Browse files Browse the repository at this point in the history
Before checking if an animation frame is not used (numFrames < 1),
make sure that the addressed frame is actually present in the loops vector.
Fixes #14491 affecting blackwell2, mountainsofmadness and possibly others
  • Loading branch information
tag2015 committed Jun 1, 2023
1 parent 2b77bbd commit e97a4ac
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion engines/ags/engine/ac/character.cpp
Expand Up @@ -1711,7 +1711,11 @@ void start_character_turning(CharacterInfo *chinf, int useloop, int no_diagonal)
break;
if ((turnlooporder[ii] >= 4) && (no_diagonal > 0))
continue;
if (_GP(views)[chinf->view].loops[turnlooporder[ii]].numFrames < 1)
// Upstream does not do this check
// The value of turnlooporder should be checked before addressing the
// loops vector, to avoid going OOB and triggering an assertion
if (((uint)turnlooporder[ii] < _GP(views)[chinf->view].loops.size()) &&
(_GP(views)[chinf->view].loops[turnlooporder[ii]].numFrames < 1))
continue;
if (turnlooporder[ii] < _GP(views)[chinf->view].numLoops)
chinf->walking += TURNING_AROUND;
Expand Down

0 comments on commit e97a4ac

Please sign in to comment.