Skip to content

Commit 9ab97a8

Browse files
authored
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.
2 parents 07ea35f + 77c70a8 commit 9ab97a8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/bootstrap/util.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ pub fn symlink_dir(src: &Path, dest: &Path) -> io::Result<()> {
288288
nOutBufferSize: DWORD,
289289
lpBytesReturned: LPDWORD,
290290
lpOverlapped: LPOVERLAPPED) -> BOOL;
291+
fn CloseHandle(hObject: HANDLE) -> BOOL;
291292
}
292293

293294
fn to_u16s<S: AsRef<OsStr>>(s: S) -> io::Result<Vec<u16>> {
@@ -341,11 +342,13 @@ pub fn symlink_dir(src: &Path, dest: &Path) -> io::Result<()> {
341342
&mut ret,
342343
ptr::null_mut());
343344

344-
if res == 0 {
345+
let out = if res == 0 {
345346
Err(io::Error::last_os_error())
346347
} else {
347348
Ok(())
348-
}
349+
};
350+
CloseHandle(h);
351+
out
349352
}
350353
}
351354
}

0 commit comments

Comments
 (0)