diff options
author | Thierry Crozat | 2017-10-06 00:59:11 +0100 |
---|---|---|
committer | Thierry Crozat | 2017-10-06 01:01:16 +0100 |
commit | a6caf3a951b695c6f42683598043531f82a54b20 (patch) | |
tree | 99bb57c40a3f31cd84f474d5f739e83a5d3e5ce3 /engines | |
parent | 448779ad8ecdb3d7e95f0f475f566fe2eaf3c83f (diff) | |
download | scummvm-rg350-a6caf3a951b695c6f42683598043531f82a54b20.tar.gz scummvm-rg350-a6caf3a951b695c6f42683598043531f82a54b20.tar.bz2 scummvm-rg350-a6caf3a951b695c6f42683598043531f82a54b20.zip |
MOHAWK: 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')
-rw-r--r-- | engines/mohawk/riven_scripts.cpp | 4 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index cb040ee4a0..18a3597086 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -147,13 +147,13 @@ void RivenScriptManager::runQueuedScripts() { _runningQueuedScripts = false; } -RivenScriptPtr RivenScriptManager::createScriptFromData(uint16 commandCount, ...) { +RivenScriptPtr RivenScriptManager::createScriptFromData(uint commandCount, ...) { va_list args; va_start(args, commandCount); // Build a script from the variadic arguments Common::MemoryWriteStreamDynamic writeStream = Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); - writeStream.writeUint16BE(commandCount); + writeStream.writeUint16BE((uint16)commandCount); for (uint i = 0; i < commandCount; i++) { uint16 command = va_arg(args, int); diff --git a/engines/mohawk/riven_scripts.h b/engines/mohawk/riven_scripts.h index 25cf363450..423434fe59 100644 --- a/engines/mohawk/riven_scripts.h +++ b/engines/mohawk/riven_scripts.h @@ -179,7 +179,7 @@ public: RivenScriptPtr readScriptFromData(uint16 *data, uint16 size); /** Create a script from the caller provided arguments containing raw data */ - RivenScriptPtr createScriptFromData(uint16 commandCount, ...); + RivenScriptPtr createScriptFromData(uint commandCount, ...); /** * Create a script with a single user provided command |