未验证 提交 9ab97a87 编写于 作者: K kennytm 提交者: GitHub

Rollup merge of #49464 - ollie27:rustbuild_junction_handle_leak, r=alexcrichton

rustbuild: Don't leak file handles when creating junctions on Windows

This fixes building the compiler docs because stage1-rustc\x86_64-pc-windows-msvc\doc is used twice which doesn't work if we still have a handle from the first time.
...@@ -288,6 +288,7 @@ fn DeviceIoControl(hDevice: HANDLE, ...@@ -288,6 +288,7 @@ fn DeviceIoControl(hDevice: HANDLE,
nOutBufferSize: DWORD, nOutBufferSize: DWORD,
lpBytesReturned: LPDWORD, lpBytesReturned: LPDWORD,
lpOverlapped: LPOVERLAPPED) -> BOOL; lpOverlapped: LPOVERLAPPED) -> BOOL;
fn CloseHandle(hObject: HANDLE) -> BOOL;
} }
fn to_u16s<S: AsRef<OsStr>>(s: S) -> io::Result<Vec<u16>> { fn to_u16s<S: AsRef<OsStr>>(s: S) -> io::Result<Vec<u16>> {
...@@ -341,11 +342,13 @@ fn to_u16s<S: AsRef<OsStr>>(s: S) -> io::Result<Vec<u16>> { ...@@ -341,11 +342,13 @@ fn to_u16s<S: AsRef<OsStr>>(s: S) -> io::Result<Vec<u16>> {
&mut ret, &mut ret,
ptr::null_mut()); ptr::null_mut());
if res == 0 { let out = if res == 0 {
Err(io::Error::last_os_error()) Err(io::Error::last_os_error())
} else { } else {
Ok(()) Ok(())
} };
CloseHandle(h);
out
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册