From 21da6eddaffdf0d0742ef44f707b2b6bb0be4400 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 31 Aug 2024 21:24:45 +0300 Subject: [PATCH] Move condition away from loop header --- bddisasm/bdx86_decoder.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bddisasm/bdx86_decoder.c b/bddisasm/bdx86_decoder.c index 6e43f24..a3c759f 100644 --- a/bddisasm/bdx86_decoder.c +++ b/bddisasm/bdx86_decoder.c @@ -4427,11 +4427,19 @@ NdDecodeWithContext( Instrux->EncMode = ND_ENCM_LEGACY; // Assume legacy encoding by default. // Fetch the instruction bytes. - for (opIndex = 0; - opIndex < ((Size < ND_MAX_INSTRUCTION_LENGTH) ? Size : ND_MAX_INSTRUCTION_LENGTH); - opIndex++) + if (Size < ND_MAX_INSTRUCTION_LENGTH) { - Instrux->InstructionBytes[opIndex] = Code[opIndex]; + for (opIndex = 0; opIndex < Size; opIndex++) + { + Instrux->InstructionBytes[opIndex] = Code[opIndex]; + } + } + else + { + for (opIndex = 0; opIndex < ND_MAX_INSTRUCTION_LENGTH; opIndex++) + { + Instrux->InstructionBytes[opIndex] = Code[opIndex]; + } } if (gPrefixesMap[Instrux->InstructionBytes[0]] != ND_PREF_CODE_NONE)