[Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.95,1.96
Max Horn
fingolfin at users.sourceforge.net
Fri Mar 7 16:06:03 CET 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv28823
Modified Files:
sound.cpp
Log Message:
clean up / some more sanity checks
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- sound.cpp 7 Mar 2003 21:38:46 -0000 1.95
+++ sound.cpp 8 Mar 2003 00:05:27 -0000 1.96
@@ -1162,7 +1162,8 @@
}
int Sound::playBundleSound(char *sound) {
- byte *ptr, *orig_ptr;
+ byte *ptr = 0, *orig_ptr;
+ byte *final;
bool result;
if (_scumm->_noDigitalSamples)
@@ -1197,24 +1198,19 @@
if (_scumm->_maxRooms != 6) // CMI demo does not have .IMX for voice but does for music...
strcat(name, ".IMX");
output_size = _scumm->_bundle->decompressVoiceSampleByName(name, &ptr);
- if (output_size == 0) {
- free(ptr);
- return -1;
- }
} else {
output_size = _scumm->_bundle->decompressVoiceSampleByName(sound, &ptr);
- if (output_size == 0) {
- free(ptr);
- return -1;
- }
}
+
orig_ptr = ptr;
+ if (output_size == 0 || orig_ptr == 0) {
+ goto bail;
+ }
tag = READ_BE_UINT32(ptr); ptr += 4;
if (tag != MKID_BE('iMUS')) {
warning("Decompression of bundle sound failed");
- free(orig_ptr);
- return -1;
+ goto bail;
}
ptr += 12;
@@ -1246,11 +1242,10 @@
if (size < 0) {
warning("Decompression sound failed (no size field)");
- free(orig_ptr);
- return -1;
+ goto bail;
}
- byte *final = (byte *)malloc(size);
+ final = (byte *)malloc(size);
memcpy(final, ptr, size);
free(orig_ptr);
@@ -1268,6 +1263,11 @@
warning("Sound::playBundleSound() to do more options to playRaw...");
return -1;
}
+
+bail:
+ if (orig_ptr)
+ free(orig_ptr);
+ return -1;
}
int Sound::playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned) {
More information about the Scummvm-git-logs
mailing list