Skip to content

Commit 2fa6b9f

Browse files
committed
Update from code review
1 parent 9be8b3a commit 2fa6b9f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Diff for: library/std/src/sys/path/windows.rs

+1
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ pub(crate) fn is_absolute_exact(path: &[u16]) -> bool {
386386
if result == 0 || result as usize != buffer_len - 1 {
387387
false
388388
} else {
389+
// SAFETY: `GetFullPathNameW` initialized `result` bytes and does not exceed `nBufferLength - 1` (capacity).
389390
unsafe {
390391
new_path.set_len((result as usize) + 1);
391392
}

Diff for: library/std/src/sys/process/windows.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ fn make_dirp(d: Option<&OsString>) -> io::Result<(*const u16, Vec<u16>)> {
889889
let start = r"\\?\UN".len();
890890
dir_str[start] = b'\\' as u16;
891891
if path::is_absolute_exact(&dir_str[start..]) {
892-
unsafe { dir_str.as_ptr().add(start) }
892+
dir_str[start..].as_ptr()
893893
} else {
894894
// Revert the above change.
895895
dir_str[start] = b'C' as u16;
@@ -899,7 +899,7 @@ fn make_dirp(d: Option<&OsString>) -> io::Result<(*const u16, Vec<u16>)> {
899899
// Strip the leading `\\?\`
900900
let start = r"\\?\".len();
901901
if path::is_absolute_exact(&dir_str[start..]) {
902-
unsafe { dir_str.as_ptr().add(start) }
902+
dir_str[start..].as_ptr()
903903
} else {
904904
dir_str.as_ptr()
905905
}

0 commit comments

Comments
 (0)