Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ext/runtime/external_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ unsafe extern "C" fn allocate(
let count_loaded = allocator.count.load(Ordering::SeqCst);

if count_loaded > allocator.max {
allocator.count.fetch_sub(n, Ordering::SeqCst);
return std::ptr::null::<*mut [u8]>() as *mut c_void;
}

Expand All @@ -78,6 +79,7 @@ unsafe extern "C" fn allocate_uninitialized(
let count_loaded = allocator.count.load(Ordering::SeqCst);

if count_loaded > allocator.max {
allocator.count.fetch_sub(n, Ordering::SeqCst);
return std::ptr::null::<*mut [u8]>() as *mut c_void;
}

Expand Down Expand Up @@ -114,6 +116,9 @@ unsafe extern "C" fn reallocate(
let count_loaded = allocator.count.load(Ordering::SeqCst);

if count_loaded > allocator.max {
allocator
.count
.fetch_sub(newlen.wrapping_sub(oldlen), Ordering::SeqCst);
return std::ptr::null::<*mut [u8]>() as *mut c_void;
}

Expand Down