HDB: Guard for corrupted sound data

This commit is contained in:
Eugene Sandulenko 2019-09-20 21:54:44 +02:00
parent d16e6a7d49
commit 9d028ac4ac

View File

@ -1538,6 +1538,11 @@ void Sound::playSound(int index) {
audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
}
if (audioStream == 0) {
warning("playSound: sound %d is corrupt", index);
return;
}
g_hdb->_mixer->playStream(
Audio::Mixer::kSFXSoundType,
&_handles[soundChannel],
@ -1597,6 +1602,11 @@ void Sound::playSoundEx(int index, int channel, bool loop) {
audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
}
if (audioStream == 0) {
warning("playSoundEx: sound %d is corrupt", index);
return;
}
if (loop) {
Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
g_hdb->_mixer->playStream(