From f05280e4156df2d13d87b1639157c63ed4e3b393 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Fri, 6 May 2016 12:08:00 +0200 Subject: [PATCH] x86/x64: Fix instruction length decoder. Thanks to Peter Cawley. --- src/lj_asm_x86.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h index 86a5b0a8..02918e23 100644 --- a/src/lj_asm_x86.h +++ b/src/lj_asm_x86.h @@ -2836,9 +2836,9 @@ static uint32_t asm_x86_inslen(const uint8_t* p) case 4: result -= (prefixes & 2); /* fallthrough */ case 5: return result + (x & 15); case 6: /* Group 3. */ - if (p[1] & 0x38) return result + 2; - if ((prefixes & 2) && (x == 0x66)) return result + 4; - return result + (x & 15); + if (p[1] & 0x38) x = 2; + else if ((prefixes & 2) && (x == 0x66)) x = 4; + goto mrm; case 7: /* VEX c4/c5. */ if (LJ_32 && p[1] < 0xc0) { x = 2;