Skip to content

Commit

Permalink
getpwuid: don't return uninitialized data on unexpected OS
Browse files Browse the repository at this point in the history
This commit makes it so the function doesn't compile on unexpected OSs
instead of returning uninitialized data.
  • Loading branch information
martinvonz committed Mar 9, 2024
1 parent e926f42 commit f617aee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/os/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ fn getpwuid(name: Name) -> Result<OsString> {
if _passwd.is_null() {
return Err(super::err_null_record());
}
passwd.assume_init()
}

#[cfg(target_os = "illumos")]
Expand All @@ -282,9 +283,8 @@ fn getpwuid(name: Name) -> Result<OsString> {
if ret.is_null() {
return Err(Error::last_os_error());
}
passwd.assume_init()
}

passwd.assume_init()
};

// Extract names.
Expand Down

0 comments on commit f617aee

Please sign in to comment.