]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx: call freeaddrinfo earlier in esxUtil_ResolveHostname
authorPino Toscano <ptoscano@redhat.com>
Mon, 5 Oct 2020 09:38:09 +0000 (11:38 +0200)
committerPino Toscano <ptoscano@redhat.com>
Mon, 5 Oct 2020 14:23:35 +0000 (16:23 +0200)
Call freeaddrinfo() as soon as @result is not needed anymore, i.e. right
after getnameinfo(); this avoids calling freeaddrinfo() in two branches.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/esx/esx_util.c

index 91008733261f17abf2fb211a2e32a9cdd3f5d5b3..555158f953d54161426ac8a806a1ac647ac13603 100644 (file)
@@ -310,17 +310,15 @@ esxUtil_ResolveHostname(const char *hostname,
 
     errcode = getnameinfo(result->ai_addr, result->ai_addrlen, ipAddress,
                           ipAddress_length, NULL, 0, NI_NUMERICHOST);
+    freeaddrinfo(result);
 
     if (errcode != 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Formatting IP address for host '%s' failed: %s"), hostname,
                        gai_strerror(errcode));
-        freeaddrinfo(result);
         return -1;
     }
 
-    freeaddrinfo(result);
-
     return 0;
 }