From 49259d3f018284370c883ae54e2bbe7783d040ea Mon Sep 17 00:00:00 2001 From: Benedikt Rascher-Friesenhausen Date: Thu, 11 Oct 2018 20:59:54 +0200 Subject: [PATCH] Don't drop the host aliases pointer vector in `gethostent` There are pointers to this vector in `HOST_ENTRY` so we must keep it around for as long as `HOST_ENTRY` exists. --- src/header/netdb/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/header/netdb/mod.rs b/src/header/netdb/mod.rs index d5e199e74a..c6de7d8f07 100644 --- a/src/header/netdb/mod.rs +++ b/src/header/netdb/mod.rs @@ -120,6 +120,7 @@ static mut HOST_ENTRY: hostent = hostent { }; static mut HOST_NAME: Option> = None; static mut HOST_ALIASES: Option>> = None; +static mut _HOST_ALIASES: Option> = None; static mut HOST_ADDR: Option = None; static mut HOST_ADDR_LIST: [*mut c_char; 2] = [ptr::null_mut(); 2]; static mut _HOST_ADDR_LIST: [u8; 4] = [0u8; 4]; @@ -649,6 +650,7 @@ pub unsafe extern "C" fn gethostent() -> *const hostent { h_length: 4, h_addr_list: HOST_ADDR_LIST.as_mut_ptr(), }; + _HOST_ALIASES = Some(host_aliases); if HOST_STAYOPEN == 0 { endhostent(); }