Skip to content

Commit

Permalink
Null terminate string for windows api
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaeroxe committed Oct 17, 2023
1 parent 5c6208b commit 70d2d1c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ impl Checker for ExistedChecker {
fn matches_arch(path: &Path) -> bool {
use std::os::windows::prelude::OsStrExt;

let os_str = path.as_os_str().encode_wide().collect::<Vec<u16>>();
let os_str = path
.as_os_str()
.encode_wide()
.chain(std::iter::once(0))
.collect::<Vec<u16>>();
let mut out = 0;
let is_executable = unsafe {
windows_sys::Win32::Storage::FileSystem::GetBinaryTypeW(os_str.as_ptr(), &mut out)
Expand Down

0 comments on commit 70d2d1c

Please sign in to comment.