aboutsummaryrefslogtreecommitdiff
path: root/engines/tsage
diff options
context:
space:
mode:
authorThierry Crozat2017-10-06 01:00:27 +0100
committerThierry Crozat2017-10-08 14:51:04 +0100
commitb1ba071ea8a128f94f70f9a28270644e5d70b6fb (patch)
treea0919d9d5923aa8a4df241ea9434016b5c9335d9 /engines/tsage
parent9b374acb2b1aad5fd38fb99fdf48cc081e291b9a (diff)
downloadscummvm-rg350-b1ba071ea8a128f94f70f9a28270644e5d70b6fb.tar.gz
scummvm-rg350-b1ba071ea8a128f94f70f9a28270644e5d70b6fb.tar.bz2
scummvm-rg350-b1ba071ea8a128f94f70f9a28270644e5d70b6fb.zip
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.
Diffstat (limited to 'engines/tsage')
-rw-r--r--engines/tsage/core.cpp7
-rw-r--r--engines/tsage/core.h2
2 files changed, 6 insertions, 3 deletions
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();