Skip to content

Commit a94642c

Browse files
committed
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
2 parents 97842f5 + dc97023 commit a94642c

File tree

1 file changed

+2
-2
lines changed
  • src/libstd/sys/windows

1 file changed

+2
-2
lines changed

src/libstd/sys/windows/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,9 @@ pub fn home_dir() -> Option<PathBuf> {
338338
let _handle = Handle::new(token);
339339
super::fill_utf16_buf(|buf, mut sz| {
340340
match c::GetUserProfileDirectoryW(token, buf, &mut sz) {
341-
0 if c::GetLastError() != 0 => 0,
341+
0 if c::GetLastError() != c::ERROR_INSUFFICIENT_BUFFER => 0,
342342
0 => sz,
343-
n => n as c::DWORD,
343+
_ => sz - 1, // sz includes the null terminator
344344
}
345345
}, super::os2path).ok()
346346
})

0 commit comments

Comments
 (0)