Skip to content

Commit

Permalink
TSAGE: Fix undefined behaviour in variadic functions
Browse files Browse the repository at this point in the history
Passing a type that undergoes default argument promotion as last
argument of a variadic function results in undefined behaviour.
  • Loading branch information
criezy committed Oct 8, 2017
1 parent 9b374ac commit b1ba071
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions engines/tsage/core.cpp
Expand Up @@ -2358,8 +2358,11 @@ int SceneObject::checkRegion(const Common::Point &pt) {
return regionIndex;
}

void SceneObject::animate(AnimateMode animMode, ...) {
_animateMode = animMode;
// The parameter to the function below should really be an AnimateMode value.
// However passing an enum type as last argument of a variadic function may
// result in undefined behaviour.
void SceneObject::animate(int animMode, ...) {
_animateMode = (AnimateMode)animMode;
_updateStartFrame = g_globals->_events.getFrameNumber();
if (_numFrames)
_updateStartFrame += 60 / _numFrames;
Expand Down
2 changes: 1 addition & 1 deletion engines/tsage/core.h
Expand Up @@ -577,7 +577,7 @@ class SceneObject : public SceneHotspot {
void getHorizBounds();
int getRegionIndex();
int checkRegion(const Common::Point &pt);
void animate(AnimateMode animMode, ...);
void animate(int animMode, ...);
void checkAngle(const SceneObject *obj);
void checkAngle(const Common::Point &pt);
void hide();
Expand Down

0 comments on commit b1ba071

Please sign in to comment.