aboutsummaryrefslogtreecommitdiff
path: root/scumm/sound.cpp
diff options
context:
space:
mode:
authorTravis Howell2004-08-28 04:34:34 +0000
committerTravis Howell2004-08-28 04:34:34 +0000
commit75fd690c20c8b33a02584e32b0727145cad6e1db (patch)
tree46abed82f5ab9e8a0331febfaafef9c2ac40da5c /scumm/sound.cpp
parent4c732d15c6162a34905cf215e71012ced3d412bc (diff)
downloadscummvm-rg350-75fd690c20c8b33a02584e32b0727145cad6e1db.tar.gz
scummvm-rg350-75fd690c20c8b33a02584e32b0727145cad6e1db.tar.bz2
scummvm-rg350-75fd690c20c8b33a02584e32b0727145cad6e1db.zip
Safety check
svn-id: r14804
Diffstat (limited to 'scumm/sound.cpp')
-rw-r--r--scumm/sound.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index a336d1ccd9..fa273ed834 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -210,7 +210,7 @@ void Sound::playSound(int soundID, int offset) {
size = musicFile.readUint32LE();
if (music_offs > total_size || (size + music_offs) > total_size) {
- warning("Bad music offsets");
+ warning("playSound: Bad music offsets");
musicFile.close();
return;
}
@@ -269,7 +269,13 @@ void Sound::playSound(int soundID, int offset) {
if (READ_UINT32(ptr) != MKID('SDAT'))
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) {
// Used by the piano in Fatty Bear's Birthday Surprise
rate = _overrideFreq;