diff options
author | Matthew Hoops | 2011-07-20 09:27:39 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-07-20 09:27:39 -0400 |
commit | ad293b249e74dd1cfbdbd721d02145efbdaf9eca (patch) | |
tree | e568d96f6d7f64c5e58b4c7cd1c4fda7e649bfc7 /engines/draci/sound.cpp | |
parent | d7411acc2b1c7702280dbff1c3e1bafee528184b (diff) | |
parent | e25e85fbb047fef895ede97c3c2c73451631052c (diff) | |
download | scummvm-rg350-ad293b249e74dd1cfbdbd721d02145efbdaf9eca.tar.gz scummvm-rg350-ad293b249e74dd1cfbdbd721d02145efbdaf9eca.tar.bz2 scummvm-rg350-ad293b249e74dd1cfbdbd721d02145efbdaf9eca.zip |
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'engines/draci/sound.cpp')
-rw-r--r-- | engines/draci/sound.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/engines/draci/sound.cpp b/engines/draci/sound.cpp index 106167ef8a..d534f46a6e 100644 --- a/engines/draci/sound.cpp +++ b/engines/draci/sound.cpp @@ -67,8 +67,12 @@ void LegacySoundArchive::openArchive(const char *path) { debugC(1, kDraciArchiverDebugLevel, "Loading header"); uint totalLength = _f->readUint32LE(); + const uint kMaxSamples = 4095; // The no-sound file is exactly 16K bytes long, so don't fail on short reads - uint sampleStarts[kMaxSamples]; + uint *sampleStarts = (uint *)malloc(kMaxSamples * sizeof(uint)); + if (!sampleStarts) + error("[LegacySoundArchive::openArchive] Cannot allocate buffer for no-sound file"); + for (uint i = 0; i < kMaxSamples; ++i) { sampleStarts[i] = _f->readUint32LE(); } @@ -90,17 +94,22 @@ void LegacySoundArchive::openArchive(const char *path) { } if (_samples[_sampleCount-1]._offset + _samples[_sampleCount-1]._length != totalLength && _samples[_sampleCount-1]._offset + _samples[_sampleCount-1]._length - _samples[0]._offset != totalLength) { - // WORKAROUND: the stored length is stored with the header for sounds and without the hader for dubbing. Crazy. + // WORKAROUND: the stored length is stored with the header for sounds and without the header for dubbing. Crazy. debugC(1, kDraciArchiverDebugLevel, "Broken sound archive: %d != %d", _samples[_sampleCount-1]._offset + _samples[_sampleCount-1]._length, totalLength); closeArchive(); + + free(sampleStarts); + return; } } else { debugC(1, kDraciArchiverDebugLevel, "Archive info: empty"); } + free(sampleStarts); + // Indicate that the archive has been successfully opened _opened = true; } |