From 70d2d1c9704802546eb285217c6def3c9cc94d17 Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Mon, 9 Oct 2023 12:23:21 -0600 Subject: [PATCH] Null terminate string for windows api --- src/checker.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/checker.rs b/src/checker.rs index 9343fcc..ec1485e 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -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::>(); + let os_str = path + .as_os_str() + .encode_wide() + .chain(std::iter::once(0)) + .collect::>(); let mut out = 0; let is_executable = unsafe { windows_sys::Win32::Storage::FileSystem::GetBinaryTypeW(os_str.as_ptr(), &mut out)