Skip to content

Commit c43210f

Browse files
committed
Pass on null handle values to child process
1 parent 7aa3613 commit c43210f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

library/std/src/sys/windows/process.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -513,17 +513,15 @@ fn program_exists(path: &Path) -> Option<Vec<u16>> {
513513
impl Stdio {
514514
fn to_handle(&self, stdio_id: c::DWORD, pipe: &mut Option<AnonPipe>) -> io::Result<Handle> {
515515
match *self {
516-
// If no stdio handle is available, then inherit means that it
517-
// should still be unavailable so propagate the
518-
// INVALID_HANDLE_VALUE.
519516
Stdio::Inherit => match stdio::get_handle(stdio_id) {
520517
Ok(io) => unsafe {
521518
let io = Handle::from_raw_handle(io);
522519
let ret = io.duplicate(0, true, c::DUPLICATE_SAME_ACCESS);
523520
io.into_raw_handle();
524521
ret
525522
},
526-
Err(..) => unsafe { Ok(Handle::from_raw_handle(c::INVALID_HANDLE_VALUE)) },
523+
// If no stdio handle is available, then propagate the null value.
524+
Err(..) => unsafe { Ok(Handle::from_raw_handle(ptr::null_mut())) },
527525
},
528526

529527
Stdio::MakePipe => {
@@ -730,9 +728,9 @@ fn zeroed_startupinfo() -> c::STARTUPINFO {
730728
wShowWindow: 0,
731729
cbReserved2: 0,
732730
lpReserved2: ptr::null_mut(),
733-
hStdInput: c::INVALID_HANDLE_VALUE,
734-
hStdOutput: c::INVALID_HANDLE_VALUE,
735-
hStdError: c::INVALID_HANDLE_VALUE,
731+
hStdInput: ptr::null_mut(),
732+
hStdOutput: ptr::null_mut(),
733+
hStdError: ptr::null_mut(),
736734
}
737735
}
738736

0 commit comments

Comments
 (0)