[Scummvm-git-logs] scummvm master -> 2b00829f09609447758dc55956dd6a345b878c4b
criezy
criezy at scummvm.org
Fri Nov 10 23:21:00 CET 2017
This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
99abd640c8 HUGO: Fix undefined behaviour in variadic functions
51df06523e KYRA: Fix undefined behaviour in variadic functions
448779ad8e LURE: Fix undefined behaviour in variadic functions
a6caf3a951 MOHAWK: Fix undefined behaviour in variadic functions
9b374acb2b TONY: Fix undefined behaviour in variadic functions
b1ba071ea8 TSAGE: Fix undefined behaviour in variadic functions
2b00829f09 Merge pull request #1041 from criezy/variadic-undefined
Commit: 99abd640c82d47b6b0fd11267eec18fa528f0a0b
https://github.com/scummvm/scummvm/commit/99abd640c82d47b6b0fd11267eec18fa528f0a0b
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-10-06T01:01:11+01:00
Commit Message:
HUGO: 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.
Changed paths:
engines/hugo/display.cpp
engines/hugo/display.h
engines/hugo/inventory.cpp
engines/hugo/inventory.h
diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp
index 1762760..77df20e 100644
--- a/engines/hugo/display.cpp
+++ b/engines/hugo/display.cpp
@@ -332,7 +332,7 @@ int16 Screen::mergeLists(Rect *list, Rect *blist, const int16 len, int16 blen) {
* Process the display list
* Trailing args are int16 x,y,dx,dy for the D_ADD operation
*/
-void Screen::displayList(Dupdate update, ...) {
+void Screen::displayList(int update, ...) {
debugC(6, kDebugDisplay, "displayList()");
int16 blitLength = 0; // Length of blit list
diff --git a/engines/hugo/display.h b/engines/hugo/display.h
index 99fda0a..33a0be8 100644
--- a/engines/hugo/display.h
+++ b/engines/hugo/display.h
@@ -61,7 +61,7 @@ public:
void displayBackground();
void displayFrame(const int sx, const int sy, Seq *seq, const bool foreFl);
- void displayList(Dupdate update, ...);
+ void displayList(int update, ...);
void displayRect(const int16 x, const int16 y, const int16 dx, const int16 dy);
void drawBoundaries();
void drawRectangle(const bool filledFl, const int16 x1, const int16 y1, const int16 x2, const int16 y2, const int color);
diff --git a/engines/hugo/inventory.cpp b/engines/hugo/inventory.cpp
index 64609e6..b638322 100644
--- a/engines/hugo/inventory.cpp
+++ b/engines/hugo/inventory.cpp
@@ -139,8 +139,8 @@ void InventoryHandler::constructInventory(const int16 imageTotNumb, int displayN
* Process required action for inventory
* Returns objId under cursor (or -1) for INV_GET
*/
-int16 InventoryHandler::processInventory(const InvAct action, ...) {
- debugC(1, kDebugInventory, "processInventory(InvAct action, ...)");
+int16 InventoryHandler::processInventory(const int action, ...) {
+ debugC(1, kDebugInventory, "processInventory(int action, ...)");
int16 imageNumb; // Total number of inventory items
int displayNumb; // Total number displayed/carried
diff --git a/engines/hugo/inventory.h b/engines/hugo/inventory.h
index a57bff4..61e9009 100644
--- a/engines/hugo/inventory.h
+++ b/engines/hugo/inventory.h
@@ -49,7 +49,7 @@ public:
int16 findIconId(int16 objId);
void loadInvent(Common::SeekableReadStream &in);
- int16 processInventory(const InvAct action, ...);
+ int16 processInventory(const int action, ...);
void runInventory();
private:
Commit: 51df06523e41d1487b8b36c840509e4627363c7b
https://github.com/scummvm/scummvm/commit/51df06523e41d1487b8b36c840509e4627363c7b
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-10-06T01:01:16+01:00
Commit Message:
KYRA: 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.
Changed paths:
engines/kyra/screen_lol.cpp
engines/kyra/screen_lol.h
diff --git a/engines/kyra/screen_lol.cpp b/engines/kyra/screen_lol.cpp
index 6dd6080..2531cb4 100644
--- a/engines/kyra/screen_lol.cpp
+++ b/engines/kyra/screen_lol.cpp
@@ -54,7 +54,7 @@ Screen_LoL::~Screen_LoL() {
delete[] _grayOverlay;
}
-void Screen_LoL::fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint16 flags, ...) {
+void Screen_LoL::fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint flags, ...) {
if (!format)
return;
@@ -90,7 +90,7 @@ void Screen_LoL::fprintString(const char *format, int x, int y, uint8 col1, uint
printText(string, x, y, col1, col2);
}
-void Screen_LoL::fprintStringIntro(const char *format, int x, int y, uint8 c1, uint8 c2, uint8 c3, uint16 flags, ...) {
+void Screen_LoL::fprintStringIntro(const char *format, int x, int y, uint8 c1, uint8 c2, uint8 c3, uint flags, ...) {
char buffer[400];
va_list args;
diff --git a/engines/kyra/screen_lol.h b/engines/kyra/screen_lol.h
index 91d663d..49c6f90 100644
--- a/engines/kyra/screen_lol.h
+++ b/engines/kyra/screen_lol.h
@@ -36,8 +36,8 @@ public:
Screen_LoL(LoLEngine *vm, OSystem *system);
~Screen_LoL();
- void fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint16 flags, ...) GCC_PRINTF(2, 8);
- void fprintStringIntro(const char *format, int x, int y, uint8 c1, uint8 c2, uint8 c3, uint16 flags, ...) GCC_PRINTF(2, 9);
+ void fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint flags, ...) GCC_PRINTF(2, 8);
+ void fprintStringIntro(const char *format, int x, int y, uint8 c1, uint8 c2, uint8 c3, uint flags, ...) GCC_PRINTF(2, 9);
void drawShadedBox(int x1, int y1, int x2, int y2, int color1, int color2);
Commit: 448779ad8ecdb3d7e95f0f475f566fe2eaf3c83f
https://github.com/scummvm/scummvm/commit/448779ad8ecdb3d7e95f0f475f566fe2eaf3c83f
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-10-06T01:01:16+01:00
Commit Message:
LURE: 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.
Changed paths:
engines/lure/res_struct.cpp
engines/lure/res_struct.h
diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp
index ec1a546..286489d 100644
--- a/engines/lure/res_struct.cpp
+++ b/engines/lure/res_struct.cpp
@@ -827,9 +827,13 @@ void SequenceDelayList::loadFromStream(Common::ReadStream *stream) {
// The following classes hold the NPC schedules
-CharacterScheduleEntry::CharacterScheduleEntry(Action theAction, ...) {
+// The following function should really take a Action parameter, but the
+// behaviour is undefined if the last argument of a variadic function
+// undergoes default argument promotion, which might be the case for enum
+// types.
+CharacterScheduleEntry::CharacterScheduleEntry(int theAction, ...) {
_parent = NULL;
- _action = theAction;
+ _action = (Action)theAction;
va_list u_Arg;
va_start(u_Arg, theAction);
@@ -870,8 +874,10 @@ uint16 CharacterScheduleEntry::param(int index) {
return _params[index];
}
-void CharacterScheduleEntry::setDetails(Action theAction, ...) {
- _action = theAction;
+// The parameter to this function should really be an Action.
+// But... (see comment above for CharacterScheduleEntry(int, ...))
+void CharacterScheduleEntry::setDetails(int theAction, ...) {
+ _action = (Action)theAction;
_numParams = actionNumParams[_action];
va_list list;
diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h
index 685c55a..a8a5e5a 100644
--- a/engines/lure/res_struct.h
+++ b/engines/lure/res_struct.h
@@ -404,7 +404,7 @@ private:
int _numParams;
public:
CharacterScheduleEntry() { _action = NONE; _parent = NULL; }
- CharacterScheduleEntry(Action theAction, ...);
+ CharacterScheduleEntry(int theAction, ...);
CharacterScheduleEntry(CharacterScheduleSet *parentSet,
CharacterScheduleResource *&rec);
CharacterScheduleEntry(CharacterScheduleEntry *src);
@@ -412,7 +412,7 @@ public:
Action action() { return _action; }
int numParams() { return _numParams; }
uint16 param(int index);
- void setDetails(Action theAction, ...);
+ void setDetails(int theAction, ...);
void setDetails2(Action theAction, int numParamEntries, uint16 *paramList);
CharacterScheduleEntry *next();
CharacterScheduleSet *parent() { return _parent; }
Commit: a6caf3a951b695c6f42683598043531f82a54b20
https://github.com/scummvm/scummvm/commit/a6caf3a951b695c6f42683598043531f82a54b20
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-10-06T01:01:16+01:00
Commit Message:
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.
Changed paths:
engines/mohawk/riven_scripts.cpp
engines/mohawk/riven_scripts.h
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index cb040ee..18a3597 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 25cf363..423434f 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
Commit: 9b374acb2b1aad5fd38fb99fdf48cc081e291b9a
https://github.com/scummvm/scummvm/commit/9b374acb2b1aad5fd38fb99fdf48cc081e291b9a
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-10-06T01:01:16+01:00
Commit Message:
TONY: 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.
Changed paths:
engines/tony/mpal/mpal.cpp
engines/tony/mpal/mpal.h
diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp
index 9172843..7319509 100644
--- a/engines/tony/mpal/mpal.cpp
+++ b/engines/tony/mpal/mpal.cpp
@@ -1548,7 +1548,7 @@ void mpalFree() {
* @remarks This is the specialized version of the original single mpalQuery
* method that returns numeric results.
*/
-uint32 mpalQueryDWORD(uint16 wQueryType, ...) {
+uint32 mpalQueryDWORD(uint wQueryType, ...) {
Common::String buf;
uint32 dwRet = 0;
@@ -1744,7 +1744,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) {
* @remarks This is the specialized version of the original single mpalQuery
* method that returns a pointer or handle.
*/
-MpalHandle mpalQueryHANDLE(uint16 wQueryType, ...) {
+MpalHandle mpalQueryHANDLE(uint wQueryType, ...) {
Common::String buf;
va_list v;
va_start(v, wQueryType);
diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h
index af24c46..56448a5 100644
--- a/engines/tony/mpal/mpal.h
+++ b/engines/tony/mpal/mpal.h
@@ -394,7 +394,7 @@ void mpalFree();
* @remarks This is the specialized version of the original single mpalQuery
* method that returns numeric results.
*/
-uint32 mpalQueryDWORD(uint16 wQueryType, ...);
+uint32 mpalQueryDWORD(uint wQueryType, ...);
/**
* This is a general function to communicate with the library, to request information
@@ -405,7 +405,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...);
* @remarks This is the specialized version of the original single mpalQuery
* method that returns a pointer or handle.
*/
-MpalHandle mpalQueryHANDLE(uint16 wQueryType, ...);
+MpalHandle mpalQueryHANDLE(uint wQueryType, ...);
/**
* This is a general function to communicate with the library, to request information
Commit: b1ba071ea8a128f94f70f9a28270644e5d70b6fb
https://github.com/scummvm/scummvm/commit/b1ba071ea8a128f94f70f9a28270644e5d70b6fb
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-10-08T14:51:04+01:00
Commit Message:
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.
Changed paths:
engines/tsage/core.cpp
engines/tsage/core.h
diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp
index 985d16b..a3ed3ab 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 8b1dead..1cee491 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();
Commit: 2b00829f09609447758dc55956dd6a345b878c4b
https://github.com/scummvm/scummvm/commit/2b00829f09609447758dc55956dd6a345b878c4b
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-11-10T22:20:54Z
Commit Message:
Merge pull request #1041 from criezy/variadic-undefined
Fix undefined behaviour in variadic functions
Changed paths:
engines/hugo/display.cpp
engines/hugo/display.h
engines/hugo/inventory.cpp
engines/hugo/inventory.h
engines/kyra/screen_lol.cpp
engines/kyra/screen_lol.h
engines/lure/res_struct.cpp
engines/lure/res_struct.h
engines/mohawk/riven_scripts.cpp
engines/mohawk/riven_scripts.h
engines/tony/mpal/mpal.cpp
engines/tony/mpal/mpal.h
engines/tsage/core.cpp
engines/tsage/core.h
More information about the Scummvm-git-logs
mailing list