Fix crashes issue due to 0 is a valid index to types_, using invalid index like -1 should give a better/clearer stack trace

This commit is contained in:
ANR2ME committed 2020-08-02 14:02:49 +07:00
1 parent 8886291434
commit 5de2707633
2 files changed
+15 -3

No files matched your search

+6 -1
View File
@@ -251,7 +251,7 @@ void __NetDoState(PointerWrap &p) {
p.Do(apctlThreadID);
}
else {
actionAfterApctlMipsCall = 0;
actionAfterApctlMipsCall = -1;
apctlThreadHackAddr = 0;
apctlThreadID = 0;
}
@@ -442,6 +442,11 @@ void __NetApctlCallbacks()
//if (*error == 0)
*newState = netApctlState;
// Since 0 is a valid index to types_ we use -1 to detects if it was loaded from an old save state
if (actionAfterApctlMipsCall < 0) {
actionAfterApctlMipsCall = __KernelRegisterActionType(AfterApctlMipsCall::Create);
}
// Run mipscall. Should we skipped executing the mipscall if oldState == newState?
for (std::map<int, ApctlHandler>::iterator it = apctlHandlers.begin(); it != apctlHandlers.end(); ++it) {
DEBUG_LOG(SCENET, "ApctlCallback [ID=%i][OldState=%d][NewState=%d][Event=%d][Error=%d][ArgsPtr=%08x]", it->first, *oldState, *newState, *event, *error, it->second.argument);