From bca012ddfe613e3510e400b5204c0fdcee20f25d Mon Sep 17 00:00:00 2001 From: Sahil Siddiq Date: Sun, 21 Jul 2024 16:30:23 +0530 Subject: [PATCH] Fix incorrect operand in disassembled instruction (#2401) Disassembling the "slwi", "srwi" and "rldicr" PowerPC instructions with the "-d" option displays the wrong operands in the detailed view. This is due to an incorrect break condition in the "PPC_insert_detail_op_imm_at" function. This patch fixes #2401. --- arch/PowerPC/PPCMapping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/PowerPC/PPCMapping.c b/arch/PowerPC/PPCMapping.c index 725f4838a6..888db80bcc 100644 --- a/arch/PowerPC/PPCMapping.c +++ b/arch/PowerPC/PPCMapping.c @@ -639,7 +639,7 @@ void PPC_insert_detail_op_imm_at(MCInst *MI, unsigned index, int64_t Val, cs_ppc_op *ops = PPC_get_detail(MI)->operands; int i = PPC_get_detail(MI)->op_count - 1; - for (; i >= 0; --i) { + for (; i >= index; --i) { ops[i + 1] = ops[i]; if (i == index) break;