Skip to content

Commit

Permalink
fixup! [WIP] Make the JIT'd code completely portable.
Browse files Browse the repository at this point in the history
Fixed error where jit_error was not initialized and correct condition using wrong operator.
  • Loading branch information
hawkinsw committed Apr 28, 2024
1 parent 2e13f7c commit b10b558
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vm/ubpf_jit_arm64.c
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit b10b558

Please sign in to comment.