Add debug asserts for invalid MEMPTR

Also fixed some corruptions this uncovered
This commit is contained in:
Exzap 2023-06-15 22:18:53 +02:00
parent 7886b594a2
commit 808d1bb424
13 changed files with 193 additions and 156 deletions

View file

@ -37,7 +37,10 @@ public:
if (ptr == nullptr)
m_value = 0;
else
m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base);
{
cemu_assert_debug((uint8*)ptr >= memory_base && (uint8*)ptr <= memory_base + 0x100000000);
m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base);
}
}
constexpr MEMPTR(const MEMPTR& memptr)
@ -63,10 +66,13 @@ public:
MEMPTR& operator=(T* ptr)
{
if (ptr == nullptr)
if (ptr == nullptr)
m_value = 0;
else
m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base);
{
cemu_assert_debug((uint8*)ptr >= memory_base && (uint8*)ptr <= memory_base + 0x100000000);
m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base);
}
return *this;
}