From 15894a0e6cd18829e30b6f75f5fb276ee653c50a Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 1 Oct 2012 13:53:21 +1000 Subject: [PATCH] added more error checking around clearing code --- .../N64 System/Recompiler/Recompiler Class.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp index 4053cae04..716bafa66 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp @@ -897,8 +897,19 @@ void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON } else if (LookUpMode() == FuncFind_PhysicalLookup) { - WriteTraceF(TraceRecompiler,"Reseting Jump Table, Addr: %X len: %d",Address,((length + 3) & ~3)); - memset((BYTE *)JumpTable() + Address,0,((length + 3) & ~3)); + if (Address < RdramSize()) + { + int ClearLen = ((length + 3) & ~3); + if (Address + ClearLen > RdramSize()) + { + _Notify->BreakPoint(__FILE__,__LINE__); + ClearLen = RdramSize() - Address; + } + WriteTraceF(TraceRecompiler,"Reseting Jump Table, Addr: %X len: %d",Address,ClearLen); + memset((BYTE *)JumpTable() + Address,0,ClearLen); + } else{ + WriteTraceF(TraceRecompiler,"Ignoring reset of Jump Table, Addr: %X len: %d",Address,((length + 3) & ~3)); + } } }