[Scummvm-cvs-logs] SF.net SVN: scummvm:[53073] scummvm/trunk/engines/scumm

athrxx at users.sourceforge.net athrxx at users.sourceforge.net
Fri Oct 8 15:50:12 CEST 2010


Revision: 53073
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53073&view=rev
Author:   athrxx
Date:     2010-10-08 13:50:11 +0000 (Fri, 08 Oct 2010)

Log Message:
-----------
SCUMM/FM-TOWNS: fixed possible invalid mem access in sfx code

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/player_towns.cpp
    scummvm/trunk/engines/scumm/player_towns.h

Modified: scummvm/trunk/engines/scumm/player_towns.cpp
===================================================================
--- scummvm/trunk/engines/scumm/player_towns.cpp	2010-10-08 13:33:54 UTC (rev 53072)
+++ scummvm/trunk/engines/scumm/player_towns.cpp	2010-10-08 13:50:11 UTC (rev 53073)
@@ -118,7 +118,7 @@
 
 	int numChan = _v2 ? 1 : ptr[14];
 	for (int i = 0; i < numChan; i++) {
-		int chan = getNextFreePcmChannel(sound, i, priority);
+		int chan = allocatePcmChannel(sound, i, priority);
 		if (!chan)
 			return;
 		
@@ -156,7 +156,7 @@
 	}
 }
 
-int Player_Towns::getNextFreePcmChannel(int sound, int sfxChanRelIndex, uint32 priority) {
+int Player_Towns::allocatePcmChannel(int sound, int sfxChanRelIndex, uint32 priority) {
 	if (!_intf)
 		return 0;
 
@@ -177,7 +177,8 @@
 				continue;
 
 			chan = i;
-			_vm->_sound->stopSound(_pcmCurrentSound[chan].index);
+			if (_pcmCurrentSound[chan].index != 0xffff)
+				_vm->_sound->stopSound(_pcmCurrentSound[chan].index);
 		}
 
 		if (!chan) {
@@ -185,7 +186,7 @@
 				if (priority >= _pcmCurrentSound[i].priority)
 					chan = i;
 			}				
-			if (chan)
+			if (chan && _pcmCurrentSound[chan].index != 0xffff)
 				_vm->_sound->stopSound(_pcmCurrentSound[chan].index);
 		}
 	}
@@ -723,9 +724,7 @@
 	
 	uint32 len = (READ_LE_UINT32(data) >> 8) - 2;
 	
-	int chan = getNextFreePcmChannel(0xffff, 0, 0x1000);
-	if (!chan)
-		return;
+	int chan = allocatePcmChannel(0xffff, 0, 0x1000);
 
 	delete[] _sblData;
 	_sblData = new uint8[len + 32];

Modified: scummvm/trunk/engines/scumm/player_towns.h
===================================================================
--- scummvm/trunk/engines/scumm/player_towns.h	2010-10-08 13:33:54 UTC (rev 53072)
+++ scummvm/trunk/engines/scumm/player_towns.h	2010-10-08 13:50:11 UTC (rev 53073)
@@ -59,7 +59,7 @@
 	void playPcmTrack(int sound, const uint8 *data, int velo = 0, int pan = 64, int note = 0, int priority = 0);
 	void stopPcmTrack(int sound);
 
-	int getNextFreePcmChannel(int sound, int sfxChanRelIndex, uint32 priority);
+	int allocatePcmChannel(int sound, int sfxChanRelIndex, uint32 priority);
 
 	struct PcmCurrentSound {
 		uint16 index;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list