Only allow reset/power when core is running

If we don't check for Core::IsRunning(), event types such as
iosNotifyResetButton may actually be nullptr, or some random invalid
pointer (after an emulation start then shutdown) and be used when the
user triggers a reset, which causes random crashes.
This commit is contained in:
Léo Lam 2017-01-19 22:08:13 +01:00
parent 629fcb437a
commit a000a3c23f
1 changed files with 4 additions and 0 deletions

View File

@ -230,6 +230,8 @@ static void IOSNotifyPowerButtonCallback(u64 userdata, s64 cyclesLate)
void ResetButton_Tap() void ResetButton_Tap()
{ {
if (!Core::IsRunning())
return;
CoreTiming::ScheduleEvent(0, toggleResetButton, true, CoreTiming::FromThread::ANY); CoreTiming::ScheduleEvent(0, toggleResetButton, true, CoreTiming::FromThread::ANY);
CoreTiming::ScheduleEvent(0, iosNotifyResetButton, 0, CoreTiming::FromThread::ANY); CoreTiming::ScheduleEvent(0, iosNotifyResetButton, 0, CoreTiming::FromThread::ANY);
CoreTiming::ScheduleEvent(SystemTimers::GetTicksPerSecond() / 2, toggleResetButton, false, CoreTiming::ScheduleEvent(SystemTimers::GetTicksPerSecond() / 2, toggleResetButton, false,
@ -238,6 +240,8 @@ void ResetButton_Tap()
void PowerButton_Tap() void PowerButton_Tap()
{ {
if (!Core::IsRunning())
return;
CoreTiming::ScheduleEvent(0, iosNotifyPowerButton, 0, CoreTiming::FromThread::ANY); CoreTiming::ScheduleEvent(0, iosNotifyPowerButton, 0, CoreTiming::FromThread::ANY);
} }