Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit b9d21f4

Browse files
authored
Backport #505 and #513 to v0.6 (#516)
* Adds error message in case std::alloc::alloc() fails. (#505) * Stops using assign as that drops the previously (non) existing value. (#513)
1 parent d91f880 commit b9d21f4

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/jit.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,9 +1259,10 @@ impl<'a, V: Verifier, C: ContextObject> JitCompiler<'a, V, C> {
12591259

12601260
// Routine for allocating errors
12611261
self.set_anchor(ANCHOR_ALLOCATE_EXCEPTION);
1262-
unsafe fn allocate_error(result: &mut ProgramResult) -> *mut EbpfError {
1262+
unsafe fn allocate_error(result: *mut ProgramResult) -> *mut EbpfError {
12631263
let err_ptr = std::alloc::alloc(std::alloc::Layout::new::<EbpfError>()) as *mut EbpfError;
1264-
*result = ProgramResult::Err(Box::from_raw(err_ptr));
1264+
assert!(!err_ptr.is_null(), "std::alloc::alloc() failed");
1265+
result.write(ProgramResult::Err(Box::from_raw(err_ptr)));
12651266
err_ptr
12661267
}
12671268
self.emit_ins(X86Instruction::lea(OperandSize::S64, RBP, R10, Some(X86IndirectAccess::Offset(self.slot_on_environment_stack(RuntimeEnvironmentSlot::ProgramResult)))));

0 commit comments

Comments
 (0)