diff options
-rw-r--r-- | v5/apf_interpreter.c | 4 | ||||
-rw-r--r-- | v5/apf_interpreter_source.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/v5/apf_interpreter.c b/v5/apf_interpreter.c index 7e31b4d..00576f8 100644 --- a/v5/apf_interpreter.c +++ b/v5/apf_interpreter.c @@ -770,11 +770,13 @@ static int do_apf_run(apf_context* ctx) { case JGT_OPCODE: case JLT_OPCODE: case JSET_OPCODE: { + /* with len_field == 0, we have imm == 0 and thus a jmp +0, ie. a no-op */ + if (len_field == 0) break; /* Load second immediate field. */ u32 cmp_imm = 0; if (reg_num == 1) { cmp_imm = ctx->R[1]; - } else if (len_field != 0) { + } else { u32 cmp_imm_len = 1 << (len_field - 1); cmp_imm = decode_imm(ctx, cmp_imm_len); /* 2nd imm, at worst 8 bytes past prog_len */ } diff --git a/v5/apf_interpreter_source.c b/v5/apf_interpreter_source.c index 67d11ec..5246451 100644 --- a/v5/apf_interpreter_source.c +++ b/v5/apf_interpreter_source.c @@ -237,11 +237,13 @@ static int do_apf_run(apf_context* ctx) { case JGT_OPCODE: case JLT_OPCODE: case JSET_OPCODE: { + // with len_field == 0, we have imm == 0 and thus a jmp +0, ie. a no-op + if (len_field == 0) break; // Load second immediate field. u32 cmp_imm = 0; if (reg_num == 1) { cmp_imm = ctx->R[1]; - } else if (len_field != 0) { + } else { u32 cmp_imm_len = 1 << (len_field - 1); cmp_imm = decode_imm(ctx, cmp_imm_len); // 2nd imm, at worst 8 bytes past prog_len } |