Add some sanity checks when looking up syscalls.

This may avoid crashing the emu when it starts executing junk (still not good of course, heh).
This commit is contained in:
Henrik Rydgard committed 2014-06-08 13:03:03 +02:00
1 parent fe58f8daa9
commit a31194a877
1 file changed
+11 -4
+11 -4
View File
@@ -477,9 +477,16 @@ const HLEFunction *GetSyscallInfo(MIPSOpcode op)
u32 callno = (op >> 6) & 0xFFFFF; //20 bits
int funcnum = callno & 0xFFF;
int modulenum = (callno & 0xFF000) >> 12;
if (funcnum == 0xfff)
{
ERROR_LOG(HLE,"Unknown syscall: Module: %s", modulenum > (int) moduleDB.size() ? "(unknown)" : moduleDB[modulenum].name);
if (funcnum == 0xfff) {
ERROR_LOG(HLE, "Unknown syscall: Module: %s", modulenum > (int) moduleDB.size() ? "(unknown)" : moduleDB[modulenum].name);
return NULL;
}
if (modulenum >= moduleDB.size()) {
ERROR_LOG(HLE, "Syscall had bad module number %i - probably executing garbage", modulenum);
return NULL;
}
if (funcnum >= moduleDB[modulenum].numFunctions) {
ERROR_LOG(HLE, "Syscall had bad function number %i in module %i - probably executing garbage", funcnum, modulenum);
return NULL;
}
return &moduleDB[modulenum].funcTable[funcnum];
@@ -525,7 +532,7 @@ void CallSyscall(MIPSOpcode op)
CallSyscallWithoutFlags(info);
}
else
ERROR_LOG_REPORT(HLE, "Unimplemented HLE function %s", info->name);
ERROR_LOG_REPORT(HLE, "Unimplemented HLE function %s", info->name ? info->name : "(???)");
if (g_Config.bShowDebugStats)
{