Safety check

svn-id: r14804
This commit is contained in:
Travis Howell 2004-08-28 04:34:34 +00:00
parent 4c732d15c6
commit 75fd690c20

View File

@ -210,7 +210,7 @@ void Sound::playSound(int soundID, int offset) {
size = musicFile.readUint32LE(); size = musicFile.readUint32LE();
if (music_offs > total_size || (size + music_offs) > total_size) { if (music_offs > total_size || (size + music_offs) > total_size) {
warning("Bad music offsets"); warning("playSound: Bad music offsets");
musicFile.close(); musicFile.close();
return; return;
} }
@ -269,7 +269,13 @@ void Sound::playSound(int soundID, int offset) {
if (READ_UINT32(ptr) != MKID('SDAT')) if (READ_UINT32(ptr) != MKID('SDAT'))
return; // abort return; // abort
size = READ_BE_UINT32(ptr+4) - offset - 8; size = READ_BE_UINT32(ptr+4) - 8;
if (offset > size) {
warning("playSound: Bad sound offset");
offset = 0;
}
size -= offset;
if (_overrideFreq) { if (_overrideFreq) {
// Used by the piano in Fatty Bear's Birthday Surprise // Used by the piano in Fatty Bear's Birthday Surprise
rate = _overrideFreq; rate = _overrideFreq;