aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/fmv/theora_decoder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sword25/fmv/theora_decoder.cpp')
-rw-r--r--engines/sword25/fmv/theora_decoder.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/engines/sword25/fmv/theora_decoder.cpp b/engines/sword25/fmv/theora_decoder.cpp
index 098bd2c6b9..a7ebb5df8c 100644
--- a/engines/sword25/fmv/theora_decoder.cpp
+++ b/engines/sword25/fmv/theora_decoder.cpp
@@ -424,6 +424,12 @@ bool TheoraDecoder::queueAudio() {
if (!_audStream)
return false;
+ // An audio buffer should have been allocated (either in the constructor or after queuing the current buffer)
+ if (!_audiobuf) {
+ warning("[TheoraDecoder::queueAudio] Invalid audio buffer");
+ return false;
+ }
+
bool queuedAudio = false;
for (;;) {
@@ -454,6 +460,11 @@ bool TheoraDecoder::queueAudio() {
// The audio mixer is now responsible for the old audio buffer.
// We need to create a new one.
_audiobuf = (ogg_int16_t *)malloc(AUDIOFD_FRAGSIZE * sizeof(ogg_int16_t));
+ if (!_audiobuf) {
+ warning("[TheoraDecoder::queueAudio] Cannot allocate memory for audio buffer");
+ return false;
+ }
+
_audiobufFill = 0;
queuedAudio = true;
}