Rollup merge of #126854 - devnexen:std_unix_os_fallback_upd, r=Mark-S… · rust-lang/rust@9892b3e (original) (raw)

File tree

1 file changed

lines changed

1 file changed

lines changed

Original file line number Diff line number Diff line change
@@ -738,17 +738,17 @@ pub fn home_dir() -> Option {
738 738 n => n as usize,
739 739 };
740 740 let mut buf = Vec::with_capacity(amt);
741 -let mut passwd: libc::passwd = mem::zeroed();
741 +let mut p = mem::MaybeUninit::libc::passwd\::uninit();
742 742 let mut result = ptr::null_mut();
743 743 match libc::getpwuid_r(
744 744 libc::getuid(),
745 -&mut passwd,
745 +p.as_mut_ptr(),
746 746 buf.as_mut_ptr(),
747 747 buf.capacity(),
748 748 &mut result,
749 749 ) {
750 750 0 if !result.is_null() => {
751 -let ptr = passwd.pw_dir as *const _;
751 +let ptr = (*result).pw_dir as *const _;
752 752 let bytes = CStr::from_ptr(ptr).to_bytes().to_vec();
753 753 Some(OsStringExt::from_vec(bytes))
754 754 }