aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2009-11-03 20:49:53 +0000
committerMax Horn2009-11-03 20:49:53 +0000
commit45308a2bd5e2aa0cff92375fac877a0b1a166d93 (patch)
tree4c8af68632d9b274c9ce2cf7077363c2a702bcce /sound
parent0fd0d1a09f5e40c65cb62d2bb4285492d7a96524 (diff)
downloadscummvm-rg350-45308a2bd5e2aa0cff92375fac877a0b1a166d93.tar.gz
scummvm-rg350-45308a2bd5e2aa0cff92375fac877a0b1a166d93.tar.bz2
scummvm-rg350-45308a2bd5e2aa0cff92375fac877a0b1a166d93.zip
Fix for bug #2890038 (FT: Crashes when entering inventory)
svn-id: r45638
Diffstat (limited to 'sound')
-rw-r--r--sound/audiostream.cpp2
-rw-r--r--sound/voc.cpp8
2 files changed, 8 insertions, 2 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp
index 783a5733b3..7d3cf935aa 100644
--- a/sound/audiostream.cpp
+++ b/sound/audiostream.cpp
@@ -220,6 +220,8 @@ public:
: _rate(rate), _stream(stream), _beginLoop(beginLoop), _endLoop(endLoop), _disposeAfterUse(disposeStream),
_audioBlockCount(numBlocks), _loop(loop) {
+ assert(numBlocks > 0);
+
// Allocate streaming buffer
if (is16Bit) {
_buffer = (byte *)malloc(BUFFER_SIZE * sizeof(int16));
diff --git a/sound/voc.cpp b/sound/voc.cpp
index 9179f5e7e5..5db32693eb 100644
--- a/sound/voc.cpp
+++ b/sound/voc.cpp
@@ -180,7 +180,6 @@ int parseVOCFormat(Common::SeekableReadStream& stream, LinearDiskStreamAudioBloc
debug(2, "parseVOCFormat");
-
if (stream.read(&fileHeader, 8) != 8)
goto invalid;
@@ -301,7 +300,12 @@ AudioStream *makeVOCDiskStream(Common::SeekableReadStream &stream, byte flags, b
int numBlocks = parseVOCFormat(stream, block, rate, loops, begin_loop, end_loop);
- AudioStream *audioStream = makeLinearDiskStream(&stream, block, numBlocks, rate, flags, takeOwnership, begin_loop, end_loop);
+ AudioStream *audioStream = 0;
+
+ // Create an audiostream from the data. Note the numBlocks may be 0,
+ // e.g. when invalid data is encountered. See bug #2890038.
+ if (numBlocks)
+ audioStream = makeLinearDiskStream(&stream, block, numBlocks, rate, flags, takeOwnership, begin_loop, end_loop);
delete[] block;