TSAGE: Fix undefined behaviour in variadic functions

Passing a type that undergoes default argument promotion as last
argument of a variadic function results in undefined behaviour.
This commit is contained in:
Thierry Crozat 2017-10-06 01:00:27 +01:00
parent 9b374acb2b
commit b1ba071ea8
2 changed files with 6 additions and 3 deletions

View File

@ -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;

View File

@ -577,7 +577,7 @@ public:
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();