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
This commit is contained in:
Junjie Huang
2022-09-13 18:25:33 +08:00
committed by GitHub
parent 50a7472bbc
commit 8da0e73634
2 changed files with 7 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"tauri-plugin-single-instance": patch
---
fix dangling pointers caused by passing `encode_wide().as_ptr()` directly to FFI on Windows.
+2 -1
View File
@@ -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(),
)
};