fix(windows): fix dangling pointers (#14)

* fix(windows): fix dangling pointers

a fix to some dangling problem same as https://github.com/tauri-apps/tauri-plugin-single-instance/pull/6

* doc(change): add a change md
pull/72/head
Junjie Huang 3 years ago committed by GitHub
parent 50a7472bbc
commit 8da0e73634
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
"tauri-plugin-single-instance": patch
---
fix dangling pointers caused by passing `encode_wide().as_ptr()` directly to FFI on Windows.

@ -33,12 +33,13 @@ pub fn init<R: Runtime>(f: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
let class_name = encode_wide(format!("{}-sic", id));
let window_name = encode_wide(format!("{}-siw", id));
let mutex_name = encode_wide(format!("{}-sim", id));
let hmutex = unsafe {
CreateMutexW(
std::ptr::null(),
true.into(),
encode_wide(format!("{}-sim", id)).as_ptr(),
mutex_name.as_ptr(),
)
};

Loading…
Cancel
Save