Core/AddressSpace: Return null accessors when no game is running to prevent out-of-bounds memory accesses.
This commit is contained in:
parent
d312495934
commit
668b8d60c8
|
@ -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_gcn;
|
||||||
static CompositeAddressSpaceAccessors s_physical_address_space_accessors_wii;
|
static CompositeAddressSpaceAccessors s_physical_address_space_accessors_wii;
|
||||||
static NullAccessors s_null_accessors;
|
static NullAccessors s_null_accessors;
|
||||||
|
static bool s_initialized = false;
|
||||||
|
|
||||||
Accessors* GetAccessors(Type address_space)
|
Accessors* GetAccessors(Type address_space)
|
||||||
{
|
{
|
||||||
|
if (!s_initialized)
|
||||||
|
return &s_null_accessors;
|
||||||
|
|
||||||
// default to effective
|
// default to effective
|
||||||
switch (address_space)
|
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_gcn = {{0x00000000, &s_mem1_address_space_accessors}};
|
||||||
s_physical_address_space_accessors_wii = {{0x00000000, &s_mem1_address_space_accessors},
|
s_physical_address_space_accessors_wii = {{0x00000000, &s_mem1_address_space_accessors},
|
||||||
{0x10000000, &s_mem2_address_space_accessors}};
|
{0x10000000, &s_mem2_address_space_accessors}};
|
||||||
|
s_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Shutdown()
|
||||||
|
{
|
||||||
|
s_initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace AddressSpace
|
} // namespace AddressSpace
|
||||||
|
|
|
@ -48,5 +48,6 @@ struct Accessors
|
||||||
Accessors* GetAccessors(Type address_space);
|
Accessors* GetAccessors(Type address_space);
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
void Shutdown();
|
||||||
|
|
||||||
} // namespace AddressSpace
|
} // namespace AddressSpace
|
||||||
|
|
|
@ -70,6 +70,7 @@ void Shutdown()
|
||||||
CPU::Shutdown();
|
CPU::Shutdown();
|
||||||
DVDInterface::Shutdown();
|
DVDInterface::Shutdown();
|
||||||
DSP::Shutdown();
|
DSP::Shutdown();
|
||||||
|
AddressSpace::Shutdown();
|
||||||
Memory::Shutdown();
|
Memory::Shutdown();
|
||||||
ExpansionInterface::Shutdown();
|
ExpansionInterface::Shutdown();
|
||||||
SerialInterface::Shutdown();
|
SerialInterface::Shutdown();
|
||||||
|
|
Loading…
Reference in New Issue