aboutsummaryrefslogtreecommitdiff
path: root/sound.cpp
diff options
context:
space:
mode:
authorLionel Ulmer2002-06-02 20:28:09 +0000
committerLionel Ulmer2002-06-02 20:28:09 +0000
commit4387c22d30298575b2c5a193d0b61a3080a9bd8c (patch)
tree2c1d0974bd01307de58c25ceea2653bc09b6b617 /sound.cpp
parentda43c14569e7d83813e65e5187041ea11fccef13 (diff)
downloadscummvm-rg350-4387c22d30298575b2c5a193d0b61a3080a9bd8c.tar.gz
scummvm-rg350-4387c22d30298575b2c5a193d0b61a3080a9bd8c.tar.bz2
scummvm-rg350-4387c22d30298575b2c5a193d0b61a3080a9bd8c.zip
Small warning fix + double inclusion protection (can always be useful
:) ). svn-id: r4395
Diffstat (limited to 'sound.cpp')
-rw-r--r--sound.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/sound.cpp b/sound.cpp
index 98308ee383..d29e1b602e 100644
--- a/sound.cpp
+++ b/sound.cpp
@@ -89,7 +89,7 @@ void Scumm::processSoundQues()
);
#endif
if ((_gameId == GID_DIG) && ((data[0] == 12) || (data[0] == 14))){
- uint32 size, rate, tag, chan, bits;
+ uint32 size = 0, rate = 0, tag, chan = 0, bits = 0;
uint8 * ptr = getResourceAddress(rtSound, data[1]);
if (ptr != NULL) {
ptr+=16; /* Skip header */
@@ -125,8 +125,7 @@ void Scumm::processSoundQues()
else if (chan == 2) {
_mixer->play_raw(NULL, buffer, size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_STEREO);
}
- }
- if (bits == 12) {
+ } else if (bits == 12) {
uint32 s_size = (size * 4) / 3;
byte * buffer = (byte*)malloc (s_size + 4);
uint32 l = 0, r = 0, tmp;
@@ -853,7 +852,7 @@ void Scumm::decompressBundleSound(int index) {
{ /* Parse decompressed data */
int rate = 22050;
byte *ptr = CompFinal;
- int tag, size;
+ int tag, size = -1;
tag = READ_BE_UINT32(ptr); ptr+=4;
if (tag != MKID_BE('iMUS')) {
warning("Decompression of bundle sound failed");
@@ -884,6 +883,11 @@ void Scumm::decompressBundleSound(int index) {
}
}
+ if (size < 0) {
+ warning("Decompression of bundle sound failed (no size field)");
+ free(CompFinal);
+ return;
+ }
Final = (unsigned char *)malloc(size);
memcpy(&Final[0], &ptr[0], size);
_mixer->play_raw(NULL, Final, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);