dynarec: check null codeBuffer in rewrite() if called before init

Fixes MINIDUMP-1VN, MINIDUMP-1X1, MINIDUMP-1XD
This commit is contained in:
Flyinghead 2023-10-13 11:41:18 +02:00
parent 56107b3667
commit 2a364dee67
4 changed files with 13 additions and 1 deletions

View File

@ -778,6 +778,9 @@ bool Arm32Dynarec::rewrite(host_context_t& context, void *faultAddress)
u32 full;
};
if (codeBuffer == nullptr)
// init() not called yet
return false;
if ((u8 *)context.pc < (u8 *)codeBuffer->getBase()
|| (u8 *)context.pc >= (u8 *)codeBuffer->getBase() + codeBuffer->getSize())
return false;

View File

@ -2312,6 +2312,9 @@ public:
8,
};
if (codeBuffer == nullptr)
// init() not called yet
return false;
//LOGI("Sh4Dynarec::rewrite pc %zx\n", context.pc);
u32 *code_ptr = (u32 *)CC_RX2RW(context.pc);
if ((u8 *)code_ptr < (u8 *)codeBuffer->getBase()
@ -2355,7 +2358,7 @@ public:
private:
Arm64Assembler* compiler = nullptr;
bool restarting = false;
Sh4CodeBuffer *codeBuffer;
Sh4CodeBuffer *codeBuffer = nullptr;
};
static Arm64Dynarec instance;

View File

@ -1360,6 +1360,9 @@ public:
bool rewrite(host_context_t &context, void *faultAddress) override
{
if (codeBuffer == nullptr)
// init() not called yet
return false;
void* protStart = codeBuffer->get();
size_t protSize = codeBuffer->getFreeSpace();
virtmem::jit_set_exec(protStart, protSize, false);

View File

@ -924,6 +924,9 @@ public:
bool rewrite(host_context_t &context, void *faultAddress) override
{
if (codeBuffer == nullptr)
// init() not called yet
return false;
u8 *rewriteAddr = *(u8 **)context.esp - 5;
X86Compiler *compiler = new X86Compiler(*codeBuffer, rewriteAddr);
bool rv = compiler->rewriteMemAccess(context);