Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

fix(windows): stop the activation variant from freeing a stack pointer

tonhowtf08eaa6c42138
diff --git a/src-tauri/omnidisc-media/src/capture/windows/audio.rs b/src-tauri/omnidisc-media/src/capture/windows/audio.rs
index 500ad4f9..856ef66c 100644
--- a/src-tauri/omnidisc-media/src/capture/windows/audio.rs
+++ b/src-tauri/omnidisc-media/src/capture/windows/audio.rs
@@ -142,9 +142,13 @@ fn activate(pid: u32, include_tree: bool) -> Result<IAudioClient, StreamError> {
},
},
};
- let mut prop = PROPVARIANT::default();
- // SAFETY: VT_BLOB borrows `params` for the duration of the call only;
- // `ActivateAudioInterfaceAsync` copies the blob before returning.
+ // Never let this variant be dropped: PROPVARIANT's Drop runs
+ // PropVariantClear, which for VT_BLOB hands pBlobData to the COM allocator —
+ // and this blob points at the stack local above. Freeing that corrupts the
+ // heap, which is precisely how this failed the first time. The variant only
+ // borrows `params` for the duration of the call, so there is nothing to
+ // release either way.
+ let mut prop = std::mem::ManuallyDrop::new(PROPVARIANT::default());
unsafe {
let inner: &mut PROPVARIANT_0_0 = &mut prop.Anonymous.Anonymous;
inner.vt = VT_BLOB;