mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
avoid zero sized allocation in false
This commit is contained in:
parent
b94a046b0d
commit
d88894c365
1 changed files with 18 additions and 10 deletions
|
@ -134,6 +134,14 @@ pub extern "C" fn rust_main() -> i32 {
|
|||
|
||||
unsafe fn call_the_closure(closure_data_ptr: *const u8) -> i64 {
|
||||
let size = size_Fx_result() as usize;
|
||||
if size == 0 {
|
||||
call_Fx(
|
||||
// This flags pointer will never get dereferenced
|
||||
MaybeUninit::uninit().as_ptr(),
|
||||
closure_data_ptr as *const u8,
|
||||
std::ptr::null_mut(),
|
||||
);
|
||||
} else {
|
||||
let layout = Layout::array::<u8>(size).unwrap();
|
||||
let buffer = std::alloc::alloc(layout) as *mut u8;
|
||||
|
||||
|
@ -145,7 +153,7 @@ unsafe fn call_the_closure(closure_data_ptr: *const u8) -> i64 {
|
|||
);
|
||||
|
||||
std::alloc::dealloc(buffer, layout);
|
||||
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue