diff options
author | Max Horn | 2003-03-07 01:35:54 +0000 |
---|---|---|
committer | Max Horn | 2003-03-07 01:35:54 +0000 |
commit | 7222d05d68cb03a6bbffa98329f8109ca5a2aaca (patch) | |
tree | bda29848c4dbfa83a4fd643afc0cd7bb0c754f14 /scumm/sound.cpp | |
parent | fd2e1c241302ff43c28df964a4459a304c60ba7e (diff) | |
download | scummvm-rg350-7222d05d68cb03a6bbffa98329f8109ca5a2aaca.tar.gz scummvm-rg350-7222d05d68cb03a6bbffa98329f8109ca5a2aaca.tar.bz2 scummvm-rg350-7222d05d68cb03a6bbffa98329f8109ca5a2aaca.zip |
uhh - code did modify ptr, then free() it (even before my change, which exposed the problem by always freeing, not just upon errors
svn-id: r6729
Diffstat (limited to 'scumm/sound.cpp')
-rw-r--r-- | scumm/sound.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 5540a8dd56..b54d8be1d0 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -1160,7 +1160,7 @@ void Sound::bundleMusicHandler(Scumm *scumm) { } int Sound::playBundleSound(char *sound) { - byte *ptr; + byte *ptr, *orig_ptr; bool result; if (_scumm->_noDigitalSamples) @@ -1197,23 +1197,24 @@ int Sound::playBundleSound(char *sound) { ptr = (byte *)malloc(1000000); output_size = _scumm->_bundle->decompressVoiceSampleByName(name, ptr); if (output_size == 0) { - delete ptr; + free(ptr); return -1; } } else { ptr = (byte *)malloc(1000000); output_size = _scumm->_bundle->decompressVoiceSampleByName(sound, ptr); if (output_size == 0) { - delete ptr; + free(ptr); return -1; } } assert(output_size <= 1000000); + orig_ptr = ptr; tag = READ_BE_UINT32(ptr); ptr += 4; if (tag != MKID_BE('iMUS')) { warning("Decompression of bundle sound failed"); - free(ptr); + free(orig_ptr); return -1; } @@ -1252,7 +1253,7 @@ int Sound::playBundleSound(char *sound) { byte *final = (byte *)malloc(size); memcpy(final, ptr, size); - free(ptr); + free(orig_ptr); if (_scumm->_actorToPrintStrFor != 0xFF && _scumm->_actorToPrintStrFor != 0) { Actor *a = _scumm->derefActorSafe(_scumm->_actorToPrintStrFor, "playBundleSound"); |