[Scummvm-git-logs] scummvm master -> cb2cc2addeee721aa8066db8c66939b5a065cf0e

eriktorbjorn noreply at scummvm.org
Sat Feb 3 09:44:45 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
cb2cc2adde SCUMM: Fix undefined va_arg() behavior


Commit: cb2cc2addeee721aa8066db8c66939b5a065cf0e
    https://github.com/scummvm/scummvm/commit/cb2cc2addeee721aa8066db8c66939b5a065cf0e
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2024-02-03T10:40:20+01:00

Commit Message:
SCUMM: Fix undefined va_arg() behavior

The second parameter to va_arg() needs to be "compatible with the type
of the actual next argument (as promoted according to the default
argument promotions)" or "random errors will occur".

Apparently what that means is that you can't use any integer types
smaller than a signed or unsigned int. In my case, ScummVM crashed with
an illegal instruction error.

Changed paths:
    engines/scumm/players/player_mac_indy3.cpp


diff --git a/engines/scumm/players/player_mac_indy3.cpp b/engines/scumm/players/player_mac_indy3.cpp
index 9a160eeca7b..4d53143fef8 100644
--- a/engines/scumm/players/player_mac_indy3.cpp
+++ b/engines/scumm/players/player_mac_indy3.cpp
@@ -840,10 +840,10 @@ void I3MFourToneSynthDriver::setParameter(ParaType type, ...)  {
 
 	switch (type) {
 	case kDuration:
-		setDuration(va_arg(arg, uint16));
+		setDuration((uint16)va_arg(arg, uint));
 		break;
 	case kChanRate:
-		setRate(chan, va_arg(arg, uint16));
+		setRate(chan, (uint16)va_arg(arg, uint));
 		break;
 	case kChanWaveform:
 		setWaveForm(chan, ptr, va_arg(arg, uint32));
@@ -901,9 +901,9 @@ void I3MSquareWaveSynthDriver::setParameter(ParaType type, ...)  {
 	
 	switch (type) {
 	case kSwTriplet:
-		a = va_arg(arg, uint16);
-		b = va_arg(arg, uint16);
-		pushTriplet(a, b, va_arg(arg, uint16));
+		a = (uint16)va_arg(arg, uint);
+		b = (uint16)va_arg(arg, uint);
+		pushTriplet(a, b, (uint16)va_arg(arg, uint));
 		break;
 	default:
 		break;




More information about the Scummvm-git-logs mailing list