From b10b5587d10d8315e7cad838efbdff75bf6aa1b2 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Sat, 27 Apr 2024 21:50:11 -0400 Subject: [PATCH] fixup! [WIP] Make the JIT'd code completely portable. Fixed error where jit_error was not initialized and correct condition using wrong operator. --- vm/ubpf_jit_arm64.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vm/ubpf_jit_arm64.c b/vm/ubpf_jit_arm64.c index 1fa3355e..3ce6622a 100644 --- a/vm/ubpf_jit_arm64.c +++ b/vm/ubpf_jit_arm64.c @@ -181,7 +181,7 @@ static uint32_t inline align_to(uint32_t amount, uint64_t boundary) static void emit_bytes(struct jit_state* state, void* data, uint32_t len) { - if (!(len <= state->size || state->offset <= state->size - len)) { + if (!(len <= state->size && state->offset <= state->size - len)) { state->jit_error = NotEnoughSpace; return; } @@ -1440,6 +1440,8 @@ ubpf_translate_arm64(struct ubpf_vm* vm, uint8_t* buffer, size_t* size) state.loads = calloc(UBPF_MAX_INSTS, sizeof(state.loads[0])); state.num_jumps = 0; state.num_loads = 0; + state.jit_error = NoError; + if (!state.pc_locs || !state.jumps) { compile_result.errmsg = ubpf_error("Out of memory");