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

eriktorbjorn noreply at scummvm.org
Mon Nov 27 17:24:48 UTC 2023


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:
a8b199d110 SCUMM: Fix runaway freqmod_offset values in player_v2base (bug #13908)


Commit: a8b199d1105d50b449d26188e0bc7473cb5ff728
    https://github.com/scummvm/scummvm/commit/a8b199d1105d50b449d26188e0bc7473cb5ff728
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2023-11-27T18:24:44+01:00

Commit Message:
SCUMM: Fix runaway freqmod_offset values in player_v2base (bug #13908)

When arriving at Castle Brunwald in the Macintosh version of Indiana
Jones and the Last Crusade, we have the case where freqmod_incr is 300
and freqmod_modulo is 32. Simply subtracgint freqmod_modulo isn't enough
to keep the value in line, leading to out of bounds access.

I don't know if freqmod_incr can ever be 0, but let's account for that
case as well, by setting freqmod_offset to 0.

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


diff --git a/engines/scumm/players/player_v2base.cpp b/engines/scumm/players/player_v2base.cpp
index e352e4d1e65..57f2d09d45b 100644
--- a/engines/scumm/players/player_v2base.cpp
+++ b/engines/scumm/players/player_v2base.cpp
@@ -592,9 +592,10 @@ void Player_V2Base::next_freqs(ChannelInfo *channel) {
 	channel->d.volume    += channel->d.volume_delta;
 	channel->d.base_freq += channel->d.freq_delta;
 
-	channel->d.freqmod_offset += channel->d.freqmod_incr;
-	if (channel->d.freqmod_offset > channel->d.freqmod_modulo)
-		channel->d.freqmod_offset -= channel->d.freqmod_modulo;
+	if (channel->d.freqmod_modulo > 0)
+		channel->d.freqmod_offset = (channel->d.freqmod_offset + channel->d.freqmod_incr) % channel->d.freqmod_modulo;
+	else
+		channel->d.freqmod_offset = 0;
 
 	channel->d.freq =
 		(int)(freqmod_table[channel->d.freqmod_table + (channel->d.freqmod_offset >> 4)])




More information about the Scummvm-git-logs mailing list