Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible Double Free Issue in Mir May Compromise Exception Safety in This Crate #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions src/rust/engine/src/externs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,7 @@ pub fn with_vec<F, C, T>(c_ptr: *mut C, c_len: usize, f: F) -> T
where
F: FnOnce(&Vec<C>) -> T,
{
let cs = unsafe { Vec::from_raw_parts(c_ptr, c_len, c_len) };
let cs = std::mem::ManuallyDrop::new(unsafe { Vec::from_raw_parts(c_ptr, c_len, c_len) });
let output = f(&cs);
mem::forget(cs);
output
}
12 changes: 4 additions & 8 deletions src/rust/engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -879,9 +879,8 @@ fn with_scheduler<F, T>(scheduler_ptr: *mut Scheduler, f: F) -> T
where
F: FnOnce(&Scheduler) -> T,
{
let scheduler = unsafe { Box::from_raw(scheduler_ptr) };
let scheduler = std::mem::ManuallyDrop::new(unsafe { Box::from_raw(scheduler_ptr) });
let t = f(&scheduler);
mem::forget(scheduler);
t
}

Expand All @@ -892,9 +891,8 @@ fn with_session<F, T>(session_ptr: *mut Session, f: F) -> T
where
F: FnOnce(&Session) -> T,
{
let session = unsafe { Box::from_raw(session_ptr) };
let session = std::mem::ManuallyDrop::new(unsafe { Box::from_raw(session_ptr) });
let t = f(&session);
mem::forget(session);
t
}

Expand All @@ -905,9 +903,8 @@ fn with_execution_request<F, T>(execution_request_ptr: *mut ExecutionRequest, f:
where
F: FnOnce(&mut ExecutionRequest) -> T,
{
let mut execution_request = unsafe { Box::from_raw(execution_request_ptr) };
let mut execution_request = std::mem::ManuallyDrop::new(unsafe { Box::from_raw(execution_request_ptr) });
let t = f(&mut execution_request);
mem::forget(execution_request);
t
}

Expand All @@ -918,8 +915,7 @@ fn with_tasks<F, T>(tasks_ptr: *mut Tasks, f: F) -> T
where
F: FnOnce(&mut Tasks) -> T,
{
let mut tasks = unsafe { Box::from_raw(tasks_ptr) };
let mut tasks = std::mem::ManuallyDrop::new(unsafe { Box::from_raw(tasks_ptr) });
let t = f(&mut tasks);
mem::forget(tasks);
t
}