]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: net - Ensure addrinfo is NULL on error
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 28 Nov 2023 08:01:31 +0000 (10:01 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 30 Nov 2023 08:41:12 +0000 (10:41 +0200)
Found by static analyser.

src/lib/net.c

index 326cebe099f4fc6baf5fa3f557ffd3b1797b22e3..54adfeb7baa91dbd55d52dfc5b23208fe5447b83 100644 (file)
@@ -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;