From b1764993dd5060315c4fd49014cc3b220a42f112 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 9 Dec 2023 23:12:52 +0100 Subject: [PATCH] Fix OP_FMT_none_loc bytecode dumping Commit f404980 ("Add fused get_loc0_loc1 opcode") introduced an off-by-one (sometimes negative) array index bug because OP_get_loc1_loc1 replaced OP_get_loc0 as the first OP_FMT_none_loc opcode. --- quickjs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickjs.c b/quickjs.c index 1f5230e02..b291e8795 100644 --- a/quickjs.c +++ b/quickjs.c @@ -27165,7 +27165,7 @@ static void dump_byte_code(JSContext *ctx, int pass, printf(",%u", get_u16(tab + pos + 8)); break; case OP_FMT_none_loc: - idx = (op - OP_get_loc0) % 4; + idx = (op - OP_get_loc0_loc1) % 4; goto has_loc; case OP_FMT_loc8: idx = get_u8(tab + pos);