diff --git a/decode.c b/decode.c index 60c9868..8328f46 100644 --- a/decode.c +++ b/decode.c @@ -610,6 +610,9 @@ fd_decode(const uint8_t* buffer, size_t len_sz, int mode_int, uintptr_t address, if (reg_type == FD_RT_GPL && !(prefixes & PREFIX_REX) && instr->operands[i].size == 1 && instr->operands[i].reg >= 4) reg_type = FD_RT_GPH; + // Reject invalid segment registers + if (reg_type == FD_RT_SEG && instr->operands[i].reg >= 6) + return -1; instr->operands[i].misc = reg_type; }