aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;