diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/rustix/src/path/arg.rs | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/path/arg.rs')
-rw-r--r-- | vendor/rustix/src/path/arg.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/vendor/rustix/src/path/arg.rs b/vendor/rustix/src/path/arg.rs index 0ea673d19..3d976ce3e 100644 --- a/vendor/rustix/src/path/arg.rs +++ b/vendor/rustix/src/path/arg.rs @@ -41,7 +41,7 @@ use std::path::{Component, Components, Iter, Path, PathBuf}; /// /// # Example /// -/// ```rust +/// ``` /// # #[cfg(any(feature = "fs", feature = "net"))] /// use rustix::ffi::CStr; /// use rustix::io; @@ -950,13 +950,15 @@ where } // Taken from - // https://github.com/rust-lang/rust/blob/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys/common/small_c_string.rs + // <https://github.com/rust-lang/rust/blob/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys/common/small_c_string.rs> let mut buf = MaybeUninit::<[u8; SMALL_PATH_BUFFER_SIZE]>::uninit(); let buf_ptr = buf.as_mut_ptr() as *mut u8; + // This helps test our safety condition below. + debug_assert!(bytes.len() + 1 <= SMALL_PATH_BUFFER_SIZE); + // SAFETY: bytes.len() < SMALL_PATH_BUFFER_SIZE which means we have space for // bytes.len() + 1 u8s: - debug_assert!(bytes.len() + 1 <= SMALL_PATH_BUFFER_SIZE); unsafe { ptr::copy_nonoverlapping(bytes.as_ptr(), buf_ptr, bytes.len()); buf_ptr.add(bytes.len()).write(0); |