about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-02-13 06:47:29 +0000
committerbors <bors@rust-lang.org>2016-02-13 06:47:29 +0000
commita94642c6f50476cbabbaa27a89ca0fcbf6c89f1a (patch)
tree8a13218320a845b71f78df14611c8f8ecbc74daa /src/libstd/sys
parent97842f54c9f98d0ed97eb4becad8906b9c1ba2da (diff)
parentdc97023e3100ee651741e7c5b4d8816e0bc3583d (diff)
downloadrust-a94642c6f50476cbabbaa27a89ca0fcbf6c89f1a.tar.gz
rust-a94642c6f50476cbabbaa27a89ca0fcbf6c89f1a.zip
Auto merge of #31557 - retep998:house-directory, r=alexcrichton
This is the simple solution. I know @nodakai was working on a more complex solution that overhauled the `fill_utf16_buf` stuff.

r? @alexcrichton
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/windows/os.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs
index 48c9b70dce4..688475a7565 100644
--- a/src/libstd/sys/windows/os.rs
+++ b/src/libstd/sys/windows/os.rs
@@ -338,9 +338,9 @@ pub fn home_dir() -> Option<PathBuf> {
         let _handle = Handle::new(token);
         super::fill_utf16_buf(|buf, mut sz| {
             match c::GetUserProfileDirectoryW(token, buf, &mut sz) {
-                0 if c::GetLastError() != 0 => 0,
+                0 if c::GetLastError() != c::ERROR_INSUFFICIENT_BUFFER => 0,
                 0 => sz,
-                n => n as c::DWORD,
+                _ => sz - 1, // sz includes the null terminator
             }
         }, super::os2path).ok()
     })