[Scummvm-git-logs] scummvm master -> 55c2a6001c9213b58431b2bcbed5d8de448cf6d9

dreammaster dreammaster at scummvm.org
Fri Apr 13 01:13:40 CEST 2018


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:
55c2a6001c XEEN: Fix read of freed data in multiple rapid playFX calls


Commit: 55c2a6001c9213b58431b2bcbed5d8de448cf6d9
    https://github.com/scummvm/scummvm/commit/55c2a6001c9213b58431b2bcbed5d8de448cf6d9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-04-12T19:13:35-04:00

Commit Message:
XEEN: Fix read of freed data in multiple rapid playFX calls

Changed paths:
    engines/xeen/sound.cpp
    engines/xeen/sound_driver.cpp


diff --git a/engines/xeen/sound.cpp b/engines/xeen/sound.cpp
index be15028..9800af5 100644
--- a/engines/xeen/sound.cpp
+++ b/engines/xeen/sound.cpp
@@ -121,29 +121,29 @@ void Sound::updateSoundSettings() {
 void Sound::loadEffectsData() {
 	// Stop any prior FX
 	stopFX();
-	delete[] _effectsData;
 
-	// Load in an entire driver so we have quick access to the effects data
-	// that's hardcoded within it
-	File file("blastmus");
-	byte *effectsData = new byte[file.size()];
-	file.seek(0);
-	file.read(effectsData, file.size());
-	file.close();
-	_effectsData = effectsData;
-
-	// Locate the playFX routine
-	const byte *fx = effectsData + READ_LE_UINT16(effectsData + 10) + 12;
-	assert(READ_BE_UINT16(fx + 28) == 0x81FB);
-	uint numEffects = READ_LE_UINT16(fx + 30);
-
-	assert(READ_BE_UINT16(fx + 36) == 0x8B87);
-	const byte *table = effectsData + READ_LE_UINT16(fx + 38);
-
-	// Extract the effects offsets
-	_effectsOffsets.resize(numEffects);
-	for (uint idx = 0; idx < numEffects; ++idx)
-		_effectsOffsets[idx] = READ_LE_UINT16(&table[idx * 2]);
+	if (!_effectsData) {
+		// Load in an entire driver so we have quick access to the effects data that's hardcoded within it
+		File file("blastmus");
+		byte *effectsData = new byte[file.size()];
+		file.seek(0);
+		file.read(effectsData, file.size());
+		file.close();
+		_effectsData = effectsData;
+
+		// Locate the playFX routine
+		const byte *fx = effectsData + READ_LE_UINT16(effectsData + 10) + 12;
+		assert(READ_BE_UINT16(fx + 28) == 0x81FB);
+		uint numEffects = READ_LE_UINT16(fx + 30);
+
+		assert(READ_BE_UINT16(fx + 36) == 0x8B87);
+		const byte *table = effectsData + READ_LE_UINT16(fx + 38);
+
+		// Extract the effects offsets
+		_effectsOffsets.resize(numEffects);
+		for (uint idx = 0; idx < numEffects; ++idx)
+			_effectsOffsets[idx] = READ_LE_UINT16(&table[idx * 2]);
+	}
 }
 
 void Sound::playFX(uint effectId) {
diff --git a/engines/xeen/sound_driver.cpp b/engines/xeen/sound_driver.cpp
index 6ce10d9..e79fcdd 100644
--- a/engines/xeen/sound_driver.cpp
+++ b/engines/xeen/sound_driver.cpp
@@ -126,10 +126,7 @@ bool SoundDriver::musSkipWord(const byte *&srcP, byte param) {
 
 bool SoundDriver::cmdFreezeFrequency(const byte *&srcP, byte param) {
 	debugC(3, kDebugSound, "cmdFreezeFrequency %d", param);
-	if (param >= _channels.size())
-		warning("Invalid channel %d in cmdFreezeFrequency call", param);
-	else
-		_channels[param]._changeFrequency = false;
+	_channels[param]._changeFrequency = false;
 	return false;
 }
 





More information about the Scummvm-git-logs mailing list