From 75fd690c20c8b33a02584e32b0727145cad6e1db Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 28 Aug 2004 04:34:34 +0000 Subject: [PATCH] Safety check svn-id: r14804 --- scumm/sound.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scumm/sound.cpp b/scumm/sound.cpp index a336d1ccd9b..fa273ed834f 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;