From 7fc1623f3bd90663e84bab236b8052dbd4901b54 Mon Sep 17 00:00:00 2001 From: Michael Krasnitski Date: Tue, 28 Jan 2025 12:24:06 -0500 Subject: Fix `BnStrCompatible` impl for `&Path` --- rust/src/string.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'rust/src/string.rs') diff --git a/rust/src/string.rs b/rust/src/string.rs index dde8f550..f3b00c95 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() } } -- cgit v1.3.1