about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorOliver Middleton <olliemail27@gmail.com>2018-03-28 22:43:23 +0100
committerOliver Middleton <olliemail27@gmail.com>2018-03-28 22:43:23 +0100
commit77c70a8c47f569481a364df42b2eae72733e7d4c (patch)
tree334d359de8c2943e91c3732af48c9f1bb7f57148 /src/bootstrap
parentd87c19db6df9189a2beb43e7998d0cc5548878b3 (diff)
downloadrust-77c70a8c47f569481a364df42b2eae72733e7d4c.tar.gz
rust-77c70a8c47f569481a364df42b2eae72733e7d4c.zip
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.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/util.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs
index 07941e58838..492eceef05c 100644
--- a/src/bootstrap/util.rs
+++ b/src/bootstrap/util.rs
@@ -288,6 +288,7 @@ pub fn symlink_dir(src: &Path, dest: &Path) -> io::Result<()> {
                                nOutBufferSize: DWORD,
                                lpBytesReturned: LPDWORD,
                                lpOverlapped: LPOVERLAPPED) -> BOOL;
+            fn CloseHandle(hObject: HANDLE) -> BOOL;
         }
 
         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<()> {
                                       &mut ret,
                                       ptr::null_mut());
 
-            if res == 0 {
+            let out = if res == 0 {
                 Err(io::Error::last_os_error())
             } else {
                 Ok(())
-            }
+            };
+            CloseHandle(h);
+            out
         }
     }
 }