From 200540922937ac8b818bcb4368a04dfda9228dcb Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 17 Nov 2015 21:39:46 +0100 Subject: [PATCH] Do nothing when calling CopyToEmu with a length of 0 Gecko apparently tries to read 0 bytes from the DVD to 0x00000000. --- Source/Core/Core/HW/Memmap.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/HW/Memmap.cpp b/Source/Core/Core/HW/Memmap.cpp index 467410d75b..2255d2cb16 100644 --- a/Source/Core/Core/HW/Memmap.cpp +++ b/Source/Core/Core/HW/Memmap.cpp @@ -253,6 +253,9 @@ static inline bool ValidCopyRange(u32 address, size_t size) void CopyFromEmu(void* data, u32 address, size_t size) { + if (size == 0) + return; + if (!ValidCopyRange(address, size)) { PanicAlert("Invalid range in CopyFromEmu. %zx bytes from 0x%08x", size, address); @@ -263,6 +266,9 @@ void CopyFromEmu(void* data, u32 address, size_t size) void CopyToEmu(u32 address, const void* data, size_t size) { + if (size == 0) + return; + if (!ValidCopyRange(address, size)) { PanicAlert("Invalid range in CopyToEmu. %zx bytes to 0x%08x", size, address); @@ -273,11 +279,12 @@ void CopyToEmu(u32 address, const void* data, size_t size) void Memset(const u32 _Address, const u8 _iValue, const u32 _iLength) { + if (_iLength == 0) + return; + u8* ptr = GetPointer(_Address); if (ptr != nullptr) - { - memset(ptr,_iValue,_iLength); - } + memset(ptr, _iValue, _iLength); } std::string GetString(u32 em_address, size_t size)