We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
rust-vst2/src/host.rs
Lines 340 to 344 in 244e14b
with Box::into_raw(Box::new(self.host.clone())), the pointee is on the heap. Multiple assignments will cause the old value to leak.
Box::into_raw(Box::new(self.host.clone()))
Probable fix is like: If call_main should only be called once, adding an Atomic to guarantee assigning only once.
call_main
const UNINITIALIZED: usize = 0; const INITIALIZING: usize = 1; const INITIALIZED: usize = 2; static GLOBAL_INIT: AtomicUsize = AtomicUsize::new(UNINITIALIZED); pub struct SetGlobalDefaultError { _no_construct: (), } unsafe fn call_main(&mut self) -> Result<*mut AEffect, SetGlobalDefaultError> { if GLOBAL_INIT .compare_exchange( UNINITIALIZED, INITIALIZING, Ordering::SeqCst, Ordering::SeqCst, ) .is_ok() { LOAD_POINTER = Box::into_raw(Box::new(self.host.clone())) as *mut c_void; (self.main)(callback_wrapper::<T>) } else { Err(SetGlobalDefaultError { _no_construct: () }) } }
Otherwise change the else branch to:
else { drop(Box::from_raw(LOAD_POINTER)); LOAD_POINTER = Box::into_raw(Box::new(self.host.clone())) as *mut c_void; (self.main)(callback_wrapper::<T>) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
rust-vst2/src/host.rs
Lines 340 to 344 in 244e14b
with
Box::into_raw(Box::new(self.host.clone()))
, the pointee is on the heap. Multiple assignments will cause the old value to leak.Probable fix is like:
If
call_main
should only be called once, adding an Atomic to guarantee assigning only once.Otherwise change the else branch to:
The text was updated successfully, but these errors were encountered: