Skip to content

Commit 378a618

Browse files
author
Danek Duvall
committed
addrinfo hint in lookup_host() needs clean initialization on all platforms
Fixes #43649
1 parent ed16b0a commit 378a618

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/liblibc

Submodule liblibc updated 56 files

src/libstd/sys_common/net.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,8 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
165165
init();
166166

167167
let c_host = CString::new(host)?;
168-
let hints = c::addrinfo {
169-
ai_flags: 0,
170-
ai_family: 0,
171-
ai_socktype: c::SOCK_STREAM,
172-
ai_protocol: 0,
173-
ai_addrlen: 0,
174-
ai_addr: ptr::null_mut(),
175-
ai_canonname: ptr::null_mut(),
176-
ai_next: ptr::null_mut()
177-
};
168+
let mut hints: c::addrinfo = unsafe { mem::zeroed() };
169+
hints.ai_socktype = c::SOCK_STREAM;
178170
let mut res = ptr::null_mut();
179171
unsafe {
180172
match cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), &hints, &mut res)) {

0 commit comments

Comments
 (0)