From e8bbb6225cade62d1f4dd377feb0ce37bdc5bdc1 Mon Sep 17 00:00:00 2001 From: Michael Krasnitski Date: Tue, 28 Jan 2025 12:24:06 -0500 Subject: [PATCH] Fix `BnStrCompatible` impl for `&Path` --- rust/src/string.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/src/string.rs b/rust/src/string.rs index dde8f55078..f3b00c95c1 100644 --- a/rust/src/string.rs +++ b/rust/src/string.rs @@ -277,7 +277,9 @@ unsafe impl BnStrCompatible for &Path { type Result = Vec; fn into_bytes_with_nul(self) -> Self::Result { - self.as_os_str().as_encoded_bytes().to_vec() + let ret = CString::new(self.as_os_str().as_encoded_bytes()) + .expect("can't pass paths with internal nul bytes to core!"); + ret.into_bytes_with_nul() } }