Skip to content

Commit

Permalink
Avoid FATAL on invalid instructions during translation
Browse files Browse the repository at this point in the history
  • Loading branch information
ifratric committed Jun 12, 2024
1 parent b194d7b commit 52b38f8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion arch/x86/x86_assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,11 @@ void X86Assembler::FixInstructionAndOutput(
// as it needs not be the original size
fixed_disp = (int64_t)(mem_address) - (int64_t)(instruction_end_addr);

if (llabs(fixed_disp) > 0x7FFFFFFF) FATAL("Offset larger than 2G");
if (llabs(fixed_disp) > 0x7FFFFFFF) {
WARN("Offset larger than 2G");
tinyinst_.InvalidInstruction(module);
return;
}

xed_encoder_request_set_memory_displacement(&inst.xedd, fixed_disp, 4);
xed_error = xed_encode(&inst.xedd, tmp, sizeof(tmp), &olen);
Expand Down

0 comments on commit 52b38f8

Please sign in to comment.