aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/fmv
diff options
context:
space:
mode:
authorJulien2011-06-04 06:05:01 +0800
committerJulien2011-06-23 15:15:57 +0800
commite972c6cfd87cb5cbf1e93cf481f53add88655c42 (patch)
tree809b15141a2b8c239b8e93419e7244bfd80f2233 /engines/sword25/fmv
parent53c4a190fc2337b6f2bec943ca9016f89d8e6f2f (diff)
downloadscummvm-rg350-e972c6cfd87cb5cbf1e93cf481f53add88655c42.tar.gz
scummvm-rg350-e972c6cfd87cb5cbf1e93cf481f53add88655c42.tar.bz2
scummvm-rg350-e972c6cfd87cb5cbf1e93cf481f53add88655c42.zip
SWORD25: Add error checks after allocating memory with malloc
Diffstat (limited to 'engines/sword25/fmv')
-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;
}