[Scummvm-git-logs] scummvm master -> 27b5291df5e9dd6fa37c9896d129c2167417cc12

athrxx noreply at scummvm.org
Sat Nov 30 12:28:16 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:
27b5291df5 SCUMM: (IMS/Mac) - add sanity check/assert for inst resources


Commit: 27b5291df5e9dd6fa37c9896d129c2167417cc12
    https://github.com/scummvm/scummvm/commit/27b5291df5e9dd6fa37c9896d129c2167417cc12
Author: athrxx (athrxx at scummvm.org)
Date: 2024-11-30T13:28:03+01:00

Commit Message:
SCUMM: (IMS/Mac) - add sanity check/assert for inst resources

Changed paths:
    engines/scumm/imuse/drivers/macintosh.cpp
    engines/scumm/players/mac_sound_lowlevel.h
    engines/scumm/players/player_mac_loom_monkey.cpp
    engines/scumm/players/player_mac_new.cpp


diff --git a/engines/scumm/imuse/drivers/macintosh.cpp b/engines/scumm/imuse/drivers/macintosh.cpp
index 7d4098e0d97..e46f9323010 100644
--- a/engines/scumm/imuse/drivers/macintosh.cpp
+++ b/engines/scumm/imuse/drivers/macintosh.cpp
@@ -806,7 +806,7 @@ NewMacSoundSystem::NewMacSoundSystem(ScummEngine *vm, Audio::Mixer *mixer) : IMS
 	assert(vm);
 	_defaultInstrID = 0xFFFF;
 	_fileMan = new ScummFile(vm);
-	}
+}
 
 NewMacSoundSystem::~NewMacSoundSystem() {
 	delete _fileMan;
@@ -860,7 +860,10 @@ bool NewMacSoundSystem::loadInstruments(const char *const *fileNames, int numFil
 		ins->sndRes.push_back(getSndResource(READ_BE_UINT16(b)));
 		if (ins->sndRes[0] != nullptr)
 			memset(ins->noteSmplsMapping, 0, 128);
+
 		int8 numRanges = CLIP<int8>(b[13], 0, 7);
+		assert(sz >= 16 + numRanges * 8);
+
 		for (int ii = 0; ii < numRanges; ++ii) {
 			ins->sndRes.push_back(getSndResource(READ_BE_INT16(b + 16 + ii * 8)));
 			if (ins->sndRes.back() != nullptr) {
diff --git a/engines/scumm/players/mac_sound_lowlevel.h b/engines/scumm/players/mac_sound_lowlevel.h
index 3ffd96cfaf5..2ab09f36ed9 100644
--- a/engines/scumm/players/mac_sound_lowlevel.h
+++ b/engines/scumm/players/mac_sound_lowlevel.h
@@ -163,7 +163,7 @@ public:
 	static uint32 calcRate(uint32 outRate, uint32 factor, uint32 dataRate);
 
 private:
-	void updateStatus(Audio::Mixer::SoundType sndType);	
+	void updateStatus(Audio::Mixer::SoundType sndType);
 	MacSndChannel *findAndCheckChannel(ChanHandle h, const char *caller, byte reqSynthType) const;
 	MacSndChannel *findChannel(ChanHandle h) const;
 	Common::Array<MacSndChannel*> _channels;
diff --git a/engines/scumm/players/player_mac_loom_monkey.cpp b/engines/scumm/players/player_mac_loom_monkey.cpp
index aaee16a7fc5..e46bc477305 100644
--- a/engines/scumm/players/player_mac_loom_monkey.cpp
+++ b/engines/scumm/players/player_mac_loom_monkey.cpp
@@ -384,7 +384,7 @@ LoomMonkeyMacSnd::LoomMonkeyMacSnd(ScummEngine *vm, Audio::Mixer *mixer) : VblTa
 	_chanConfigTable(nullptr), _chanPlaying(0), _curChanConfig(0), _curSynthType(0), _curSndType(Audio::Mixer::kPlainSoundType), _mixerThread(false),
 	_restartSound(0), _lastSndType(Audio::Mixer::kPlainSoundType), _chanCbProc(this, &MacLowLevelPCMDriver::CallbackClient::sndChannelCallback),
 	_curSoundSaveVar(0), _saveVersionChange(vm->_game.id == GID_MONKEY ? 115 : 114), _legacySaveUnits(vm->_game.id == GID_MONKEY ? 3 : 5),
-	_checkSound(vm->_game.id == GID_MONKEY ? _curSound : _curSoundSaveVar) { 
+	_checkSound(vm->_game.id == GID_MONKEY ? _curSound : _curSoundSaveVar) {
 	assert(_vm);
 	assert(_mixer);
 
@@ -579,7 +579,7 @@ void LoomMonkeyMacSnd::setQuality(int qual) {
 	int csnd = _curSound;
 	int32 timeStamp = csnd ? _songTimer * 1000 + ((_songTimerInternal * 1000) / 30) : 0;
 	stopActiveSound();
-	
+
 	detectQuality();
 	if (csnd)
 		startSound(csnd, timeStamp);
@@ -741,7 +741,7 @@ void LoomMonkeyMacSnd::sendSoundCommands(int timeStamp) {
 			}
 		}
 
-		
+
 		for (int i = 0; i < 4; ++i) {
 			if (_chanPlaying & (1 << i)) {
 				_sdrv->quiet(_musChannels[i], MacLowLevelPCMDriver::kEnqueue);
diff --git a/engines/scumm/players/player_mac_new.cpp b/engines/scumm/players/player_mac_new.cpp
index 2fa9abb7e80..901c270dc95 100644
--- a/engines/scumm/players/player_mac_new.cpp
+++ b/engines/scumm/players/player_mac_new.cpp
@@ -258,7 +258,7 @@ void MacPlayerAudioStream::setMasterVolume(Audio::Mixer::SoundType type, uint16
 int MacPlayerAudioStream::readBuffer(int16 *buffer, const int numSamples) {
 	static const char errFnNames[2][8] = {"Buffers", "Drivers"};
 	int errNo = -1;
-	for (int i = 0; i < _numGroups && errNo == -1; ++i) 
+	for (int i = 0; i < _numGroups && errNo == -1; ++i)
 		errNo = !_buffers[i].size ? 0 : (_buffers[i].rateConvAcc == -1 ? 1 : -1);
 	if (errNo != -1)
 		error("%s(): init%s() must be called before playback", __FUNCTION__, errFnNames[errNo]);
@@ -721,7 +721,7 @@ bool MacSndChannel::playDoubleBuffer(byte numChan, byte bitsPerSample, uint32 ra
 		return false;
 	}
 
-	_dblBuff = new DoubleBufferIntern(getHandle(),  1024, bitsPerSample, numChan, callback, numMixChan);	
+	_dblBuff = new DoubleBufferIntern(getHandle(),  1024, bitsPerSample, numChan, callback, numMixChan);
 	setupRateConv(_drv->getStatus().deviceRate, 0x10000, rate, false);
 	_duration = _tmrInc = _tmrPos = _loopSt = _loopEnd = _rcPos = _smpWtAcc = _phase = 0;
 




More information about the Scummvm-git-logs mailing list