From b1ba071ea8a128f94f70f9a28270644e5d70b6fb Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Fri, 6 Oct 2017 01:00:27 +0100 Subject: 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. --- engines/tsage/core.cpp | 7 +++++-- engines/tsage/core.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'engines/tsage') diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 985d16b031..a3ed3abb5b 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -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; diff --git a/engines/tsage/core.h b/engines/tsage/core.h index 8b1deadaeb..1cee491b4c 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -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(); -- cgit v1.2.3