From c3819ec721220d37b90f6acaa2215492144bc6ac Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Mon, 17 Dec 2012 21:59:43 +0100 Subject: [PATCH] Fix a possible crash in audio code --- Core/HW/SasAudio.cpp | 19 ++++++++++++------- GPU/GLES/DisplayListInterpreter.cpp | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index 5846acf483..c9413b3308 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -207,7 +207,7 @@ void SasInstance::Mix(u32 outAddr) { // TODO: Special case no-resample case for speed - if (voice.vagAddr != 0) { + if (voice.type == VOICETYPE_VAG && voice.vagAddr != 0) { // Load resample history (so we can use a wide filter) resampleBuffer[0] = voice.resampleHist[0]; resampleBuffer[1] = voice.resampleHist[1]; @@ -263,10 +263,10 @@ void SasInstance::Mix(u32 outAddr) { voice.playing = false; } } - else if (voice.pcmAddr != 0) { + else if (voice.type == VOICETYPE_PCM && voice.pcmAddr != 0) { // PCM mixing should be easy, can share code with VAG } - else if (voice.noiseFreq != 0) { + else if (voice.type == VOICETYPE_NOISE && voice.noiseFreq != 0) { // Generate noise? } } @@ -301,17 +301,22 @@ void SasVoice::Reset() { } void SasVoice::KeyOn() { - on = true; - playing = true; - paused = false; envelope.KeyOn(); switch (type) { case VOICETYPE_VAG: - vag.Start(Memory::GetPointer(vagAddr), loop); + if (Memory::IsValidAddress(vagAddr)) { + vag.Start(Memory::GetPointer(vagAddr), loop); + } else { + ERROR_LOG(SAS, "Invalid VAG address %08x", vagAddr); + return; + } break; default: break; } + playing = true; + on = true; + paused = false; } void SasVoice::KeyOff() { diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index 3f4154ad11..856710c134 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -106,7 +106,7 @@ void GLES_GPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, int format) displayStride_ = stride; displayFormat_ = format; } else { - DEBUG_LOG(HLE, "Bogus framebuffer address: %08x", framebuf); + ERROR_LOG(HLE, "Bogus framebuffer address: %08x", framebuf); } }