diff --git a/rust/src/string.rs b/rust/src/string.rs index dde8f5507..f3b00c95c 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() } }