Skip to content

Commit

Permalink
Don't crash on out of memory
Browse files Browse the repository at this point in the history
Found by fault injection

Signed-off-by: Dave Thaler <[email protected]>
  • Loading branch information
dthaler committed Aug 14, 2023
1 parent f5eb301 commit f3abdad
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vm/ubpf_jit_x86_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,11 @@ ubpf_translate_x86_64(struct ubpf_vm* vm, uint8_t* buffer, size_t* size, char**
state.jumps = calloc(UBPF_MAX_INSTS, sizeof(state.jumps[0]));
state.num_jumps = 0;

if (!state.pc_locs || !state.jumps || !state.strings) {
*errmsg = ubpf_error("Out of memory");
goto out;
}

if (translate(vm, &state, errmsg) < 0) {
goto out;
}
Expand Down

0 comments on commit f3abdad

Please sign in to comment.