Skip to content

Commit

Permalink
Fix memory corruption in logging trampoline
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Biggio committed May 20, 2024
1 parent d59bbb0 commit f055de7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cplex-rs/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ impl Environment {
}

let mut new_closure = Box::new(closure);
let new_trampoline = get_trampoline(&new_closure);
let new_trampoline = get_trampoline::<F>();
macros::cpx_env_result!(unsafe {
CPXaddfuncdest(
self.inner,
channel,
&mut *new_closure as *mut _ as *mut c_void,
&mut *new_closure as *mut F as *mut c_void,
new_trampoline,
)
})?;
Expand Down
5 changes: 1 addition & 4 deletions cplex-rs/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ impl StreamType {
}
}

pub(crate) fn get_trampoline<F>(_closure: &F) -> LoggingCallback
where
F: Fn(&str),
{
pub(crate) fn get_trampoline<F: Fn(&str)>() -> LoggingCallback {
Some(trampoline::<F>)
}

Expand Down

0 comments on commit f055de7

Please sign in to comment.