Merge pull request #9328 from AdmiralCurtiss/memory-view-crash

Core/AddressSpace: Return null accessors when no game is running to prevent out-of-bounds memory accesses.
This commit is contained in:
Léo Lam 2020-12-14 03:18:45 +01:00 committed by GitHub
commit 214ea8ff18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -374,9 +374,13 @@ static SmallBlockAccessors s_fake_address_space_accessors;
static CompositeAddressSpaceAccessors s_physical_address_space_accessors_gcn;
static CompositeAddressSpaceAccessors s_physical_address_space_accessors_wii;
static NullAccessors s_null_accessors;
static bool s_initialized = false;
Accessors* GetAccessors(Type address_space)
{
if (!s_initialized)
return &s_null_accessors;
// default to effective
switch (address_space)
{
@ -420,6 +424,12 @@ void Init()
s_physical_address_space_accessors_gcn = {{0x00000000, &s_mem1_address_space_accessors}};
s_physical_address_space_accessors_wii = {{0x00000000, &s_mem1_address_space_accessors},
{0x10000000, &s_mem2_address_space_accessors}};
s_initialized = true;
}
void Shutdown()
{
s_initialized = false;
}
} // namespace AddressSpace

View File

@ -48,5 +48,6 @@ struct Accessors
Accessors* GetAccessors(Type address_space);
void Init();
void Shutdown();
} // namespace AddressSpace

View File

@ -70,6 +70,7 @@ void Shutdown()
CPU::Shutdown();
DVDInterface::Shutdown();
DSP::Shutdown();
AddressSpace::Shutdown();
Memory::Shutdown();
ExpansionInterface::Shutdown();
SerialInterface::Shutdown();