diff options
Diffstat (limited to 'src/protected_mode')
-rw-r--r-- | src/protected_mode/display.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/protected_mode/display.rs b/src/protected_mode/display.rs index 321b5b5..8124337 100644 --- a/src/protected_mode/display.rs +++ b/src/protected_mode/display.rs @@ -9,6 +9,7 @@ use crate::protected_mode::{RegSpec, Opcode, Operand, MergeMode, InstDecoder, In use yaxpeax_arch::display::DisplaySink; use yaxpeax_arch::safer_unchecked::GetSaferUnchecked as _; +use yaxpeax_arch::safer_unchecked::unreachable_kinda_unchecked as unreachable_unchecked; trait DisplaySinkExt { // `write_opcode` depends on all mnemonics being less than 32 bytes long. check that here, at @@ -2249,15 +2250,16 @@ pub(crate) fn contextualize_intel<T: DisplaySink>(instr: &Instruction, out: &mut // don't worry about checking for `instr.operands[i] != Nothing`, it would be a bug to // reach that while iterating only to `operand_count`.. out.write_fixed_size(", ")?; + // hint that accessing `inster.operands[i]` can't panic: this is useful for + // `instr.operands` and the segment selector check after. if i >= 4 { - unsafe { core::hint::unreachable_unchecked(); } + // Safety: Instruction::operands is a four-element array; operand_count is always + // low enough that 0..operand_count is a valid index. + unsafe { unreachable_unchecked(); } } if instr.operands[i as usize].is_memory() { out.write_mem_size_label(instr.mem_size)?; - if i >= 4 { - unsafe { core::hint::unreachable_unchecked(); } - } if let Some(prefix) = instr.segment_override_for_op(i) { let name = prefix.name(); out.write_char(' ')?; |