diff --git a/.changes/fix-win-dangling.md b/.changes/fix-win-dangling.md new file mode 100644 index 00000000..12c20398 --- /dev/null +++ b/.changes/fix-win-dangling.md @@ -0,0 +1,5 @@ +--- +"tauri-plugin-single-instance": patch +--- + +fix dangling pointers caused by passing `encode_wide().as_ptr()` directly to FFI on Windows. \ No newline at end of file diff --git a/src/platform_impl/windows.rs b/src/platform_impl/windows.rs index 3abec84c..3c92695e 100644 --- a/src/platform_impl/windows.rs +++ b/src/platform_impl/windows.rs @@ -33,12 +33,13 @@ pub fn init(f: Box>) -> TauriPlugin { 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(), ) };