Hello, I took a look at your sample app, and it has memory safety issue at https://github.com/S2dentik/Rust-Win32-SampleApp/blob/lab1/src/main.rs#L101
fn toWstring(str: &str) -> *const u16 {
unsafe {
let v: Vec<u16> = OsStr::new(str).encode_wide().chain(Some(0).into_iter()).collect();
return v.as_ptr();
}
}
It allocates Vec, which uses Heap buffer, and then returns pointer to a buffer, but pointer gets used after varable v is our of scope, so is dropped.
Hello, I took a look at your sample app, and it has memory safety issue at https://github.com/S2dentik/Rust-Win32-SampleApp/blob/lab1/src/main.rs#L101
It allocates Vec, which uses Heap buffer, and then returns pointer to a buffer, but pointer gets used after varable v is our of scope, so is dropped.