diff options
| author | Chris Denton <chris@chrisdenton.dev> | 2025-08-09 07:02:01 +0000 |
|---|---|---|
| committer | Chris Denton <chris@chrisdenton.dev> | 2025-08-09 07:05:12 +0000 |
| commit | 89b366955ecab610dd6392e183e83600bc02ba11 (patch) | |
| tree | 0a1731317b793c403bf4f72c3fb5db96f7369e28 /library/std/src/sys/process | |
| parent | 6d091b2baa33698682453c7bb72809554204e434 (diff) | |
Replace unsafe function with safe alternative
The `security_attributes` function is marked as safe despite taking a raw pointer which will later be used. Fortunately this function is only used internally and only in one place that has been basically the same for a decade now. However, we only ever set one bool so it's easy enough to replace with something that's actually safe.
Diffstat (limited to 'library/std/src/sys/process')
| -rw-r--r-- | library/std/src/sys/process/windows.rs | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/library/std/src/sys/process/windows.rs b/library/std/src/sys/process/windows.rs index 1ee3fbd285f..f9e15b82475 100644 --- a/library/std/src/sys/process/windows.rs +++ b/library/std/src/sys/process/windows.rs @@ -623,16 +623,10 @@ impl Stdio { // permissions as well as the ability to be inherited to child // processes (as this is about to be inherited). Stdio::Null => { - let size = size_of::<c::SECURITY_ATTRIBUTES>(); - let mut sa = c::SECURITY_ATTRIBUTES { - nLength: size as u32, - lpSecurityDescriptor: ptr::null_mut(), - bInheritHandle: 1, - }; let mut opts = OpenOptions::new(); opts.read(stdio_id == c::STD_INPUT_HANDLE); opts.write(stdio_id != c::STD_INPUT_HANDLE); - opts.security_attributes(&mut sa); + opts.inherit_handle(true); File::open(Path::new(r"\\.\NUL"), &opts).map(|file| file.into_inner()) } } |
