[Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.422,1.423
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Tue Feb 15 00:16:23 CET 2005
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29830
Modified Files:
sound.cpp
Log Message:
This should keep ScummVM from trying to free invalid pointers. I hope.
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.422
retrieving revision 1.423
diff -u -d -r1.422 -r1.423
--- sound.cpp 14 Feb 2005 10:02:34 -0000 1.422
+++ sound.cpp 15 Feb 2005 08:15:35 -0000 1.423
@@ -159,12 +159,13 @@
}
void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
+ byte *mallocedPtr = NULL;
byte *ptr;
char *sound;
int size = -1;
int rate;
byte flags = SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE;
-
+
if (_vm->_heversion >= 70 && soundID > _vm->_numSounds) {
debug(0, "playSound #%d", soundID);
@@ -233,6 +234,9 @@
_vm->_mixer->playRaw(NULL, ptr, size, 11025, flags, soundID);
return;
}
+
+ // This pointer needs to be freed
+ mallocedPtr = ptr;
} else {
debugC(DEBUG_SOUND, "playSound #%d (room %d)", soundID,
_vm->getResourceRoomNr(rtSound, soundID));
@@ -248,7 +252,6 @@
// This is rather hackish right now, but works OK. SFX are not sounding
// 100% correct, though, not sure right now what is causing this.
else if (READ_UINT32(ptr) == MKID('Mac1')) {
-
// Read info from the header
size = READ_BE_UINT32(ptr+0x60);
rate = READ_BE_UINT16(ptr+0x64);
@@ -372,9 +375,9 @@
if ((_vm->_gameId == GID_MONKEY_SEGA) && (ptr[0] != 1)) {
for (int i = 0; i < size; i++) {
ptr[i] ^= 0x16;
- if (ptr[i] >= 0x7F) {
- ptr[i] = 0xFE - ptr[i];
- ptr[i] ^= 0x80;
+ if (ptr[i] >= 0x7F) {
+ ptr[i] = 0xFE - ptr[i];
+ ptr[i] ^= 0x80;
}
}
}
@@ -457,9 +460,10 @@
case 2: // CD track resource
ptr += 0x16;
- if (soundID == _currentCDSound)
- if (pollCD() == 1)
- return;
+ if (soundID == _currentCDSound && pollCD() == 1) {
+ free(mallocedPtr);
+ return;
+ }
{
int track = ptr[0];
@@ -547,9 +551,7 @@
}
}
-
- if (soundID > _vm->_numSounds)
- delete ptr;
+ free(mallocedPtr);
}
void Sound::processSfxQueues() {
More information about the Scummvm-git-logs
mailing list