8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3108dfa + fc50aca commit 9892b3eCopy full SHA for 9892b3e
library/std/src/sys/pal/unix/os.rs
@@ -738,17 +738,17 @@ pub fn home_dir() -> Option<PathBuf> {
738
n => n as usize,
739
};
740
let mut buf = Vec::with_capacity(amt);
741
- let mut passwd: libc::passwd = mem::zeroed();
+ let mut p = mem::MaybeUninit::<libc::passwd>::uninit();
742
let mut result = ptr::null_mut();
743
match libc::getpwuid_r(
744
libc::getuid(),
745
- &mut passwd,
+ p.as_mut_ptr(),
746
buf.as_mut_ptr(),
747
buf.capacity(),
748
&mut result,
749
) {
750
0 if !result.is_null() => {
751
- let ptr = passwd.pw_dir as *const _;
+ let ptr = (*result).pw_dir as *const _;
752
let bytes = CStr::from_ptr(ptr).to_bytes().to_vec();
753
Some(OsStringExt::from_vec(bytes))
754
}
0 commit comments