cli: fix mutex names contain extra characters (#181335)

Fixes #181334
This commit is contained in:
Connor Peet 2023-05-02 08:16:17 -07:00 committed by GitHub
parent 90bf5a07e4
commit d54402822a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,7 +30,10 @@ impl AppMutex {
#[cfg(windows)]
pub fn new(name: &str) -> Result<Self, CodeError> {
let handle = unsafe { CreateMutexA(ptr::null_mut(), 0, name.as_ptr() as _) };
use std::ffi::CString;
let cname = CString::new(name).unwrap();
let handle = unsafe { CreateMutexA(ptr::null_mut(), 0, cname.as_ptr() as _) };
if !handle.is_null() {
return Ok(Self { handle });