From f36710f8b4e5d28517fdcb35ac4fefbd15734be7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 3 Feb 2004 08:53:13 +0000 Subject: [PATCH] Act more gracefully when failing to load a (VOC) sound (should help bug #889442) svn-id: r12719 --- scumm/sound.cpp | 5 +++++ sound/voc.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/scumm/sound.cpp b/scumm/sound.cpp index b66c70a406c..05a5210c3d7 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -830,6 +830,11 @@ void Sound::startSfxSound(File *file, int file_size, PlayingSoundHandle *handle, } else { input = makeVOCStream(_sfxFile); } + + if (!input) { + warning("startSfxSound failed to load sound"); + return 0; + } if (_vm->_imuseDigital) { //_vm->_imuseDigital->stopSound(kTalkSoundID); diff --git a/sound/voc.cpp b/sound/voc.cpp index 80027fb1434..ef1741111f6 100644 --- a/sound/voc.cpp +++ b/sound/voc.cpp @@ -156,6 +156,9 @@ AudioStream *makeVOCStream(byte *ptr) { int size, rate, loops; byte *data = readVOCFromMemory(ptr, size, rate, loops); + if (!data) + return 0; + return makeLinearInputStream(rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED, data, size, 0, 0); } @@ -163,6 +166,9 @@ AudioStream *makeVOCStream(File *file) { int size, rate; byte *data = loadVOCFile(file, size, rate); + if (!data) + return 0; + return makeLinearInputStream(rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED, data, size, 0, 0); }