diff options
| author | Julien | 2011-06-04 06:05:01 +0800 |
|---|---|---|
| committer | Julien | 2011-06-23 15:15:57 +0800 |
| commit | e972c6cfd87cb5cbf1e93cf481f53add88655c42 (patch) | |
| tree | 809b15141a2b8c239b8e93419e7244bfd80f2233 /engines/sword25/fmv | |
| parent | 53c4a190fc2337b6f2bec943ca9016f89d8e6f2f (diff) | |
| download | scummvm-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.cpp | 11 |
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; } |
