Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
leoetlino committed Dec 14, 2020
2 parents 3634508 + 668b8d6 commit 214ea8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Source/Core/Core/HW/AddressSpace.cpp
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions Source/Core/Core/HW/AddressSpace.h
Expand Up @@ -48,5 +48,6 @@ struct Accessors
Accessors* GetAccessors(Type address_space);

void Init();
void Shutdown();

} // namespace AddressSpace
1 change: 1 addition & 0 deletions Source/Core/Core/HW/HW.cpp
Expand Up @@ -70,6 +70,7 @@ void Shutdown()
CPU::Shutdown();
DVDInterface::Shutdown();
DSP::Shutdown();
AddressSpace::Shutdown();
Memory::Shutdown();
ExpansionInterface::Shutdown();
SerialInterface::Shutdown();
Expand Down

0 comments on commit 214ea8f

Please sign in to comment.