Skip to content

Commit e8bbb62

Browse files
committed
Fix BnStrCompatible impl for &Path
1 parent b3f2ef8 commit e8bbb62

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rust/src/string.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ unsafe impl BnStrCompatible for &Path {
277277
type Result = Vec<u8>;
278278

279279
fn into_bytes_with_nul(self) -> Self::Result {
280-
self.as_os_str().as_encoded_bytes().to_vec()
280+
let ret = CString::new(self.as_os_str().as_encoded_bytes())
281+
.expect("can't pass paths with internal nul bytes to core!");
282+
ret.into_bytes_with_nul()
281283
}
282284
}
283285

0 commit comments

Comments
 (0)