From c0c52fffe9246f4e68451b61d457e5590c7b8884 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Wed, 7 Oct 2009 19:01:14 +0000 Subject: [PATCH] AX HLE (GC): Some protection from bad data. Fixes an SMB2 crash on reset for me, might fix other random crashes, who knows. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4376 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp index 3139672321..dd5ac1ed21 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp @@ -249,24 +249,32 @@ if (m_DebuggerFrame->ScanMails) } // ---------------- -static void ReadOutPB(u32 pb_address, AXParamBlock &PB) +static bool ReadOutPB(u32 pb_address, AXParamBlock &PB) { const u16 *pSrc = (const u16 *)g_dspInitialize.pGetMemoryPointer(pb_address); + if (!pSrc) + return false; u16 *pDest = (u16 *)&PB; + // TODO: SSE. Although it won't help much. for (int p = 0; p < (int)sizeof(AXParamBlock) / 2; p++) { pDest[p] = Common::swap16(pSrc[p]); } + return true; } -static void WriteBackPB(u32 pb_address, AXParamBlock &PB) +static bool WriteBackPB(u32 pb_address, AXParamBlock &PB) { const u16 *pSrc = (const u16*)&PB; u16 *pDest = (u16 *)g_dspInitialize.pGetMemoryPointer(pb_address); + if (!pDest) + return false; + // TODO: SSE. Although it won't help much. for (size_t p = 0; p < sizeof(AXParamBlock) / 2; p++) { pDest[p] = Common::swap16(pSrc[p]); } + return true; } static void ProcessUpdates(AXParamBlock &PB) @@ -330,13 +338,18 @@ void CUCode_AX::MixAdd(short* _pBuffer, int _iSize) AXParamBlock PB; u32 blockAddr = m_addressPBs; + if (!blockAddr) + return; + // ------------ for (int i = 0; i < NUMBER_OF_PBS; i++) { - ReadOutPB(blockAddr, PB); + if (!ReadOutPB(blockAddr, PB)) + break; ProcessUpdates(PB); MixAddVoice(PB, templbuffer, temprbuffer, _iSize, false); - WriteBackPB(blockAddr, PB); + if (!WriteBackPB(blockAddr, PB)) + break; blockAddr = (PB.next_pb_hi << 16) | PB.next_pb_lo; if (!blockAddr) {