From: Aki Tuomi Date: Tue, 28 Nov 2023 08:01:31 +0000 (+0200) Subject: lib: net - Ensure addrinfo is NULL on error X-Git-Tag: 2.4.0~1875 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70e640185b565db882f7ac87384a5f7f33dbd479;p=thirdparty%2Fdovecot%2Fcore.git lib: net - Ensure addrinfo is NULL on error Found by static analyser. --- diff --git a/src/lib/net.c b/src/lib/net.c index 326cebe099..54adfeb7ba 100644 --- a/src/lib/net.c +++ b/src/lib/net.c @@ -696,10 +696,13 @@ int net_gethostbyname(const char *addr, struct ip_addr **ips, i_zero(&hints); hints.ai_socktype = SOCK_STREAM; + ai = NULL; /* save error to host_error for later use */ host_error = getaddrinfo(addr, NULL, &hints, &ai); - if (net_handle_gai_error("getaddrinfo", host_error, FALSE) != 0) + if (net_handle_gai_error("getaddrinfo", host_error, FALSE) != 0) { + i_assert(ai == NULL); return host_error; + } /* get number of IPs */ origai = ai;