diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 5f3596ad45..6cd14d01d2 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -493,8 +493,13 @@ void Memset(const u32 _Address, const u8 _iValue, const u32 _iLength, const char uint8_t *ptr = GetPointerWriteUnchecked(_Address); memset(ptr, _iValue, _iLength); } else { - for (size_t i = 0; i < _iLength; i++) - Write_U8(_iValue, (u32)(_Address + i)); + // TODO: This mainly seems to be produced by GPUCommon::PerformMemorySet, called from + // Replace_memset_jak(). Strangely, this managed to crash in Write_U8(). + for (size_t i = 0; i < _iLength; i++) { + if (Memory::IsValidAddress(_Address + i)) { + WriteUnchecked_U8(_iValue, (u32)(_Address + i)); + } + } } if (tag) {