From 9b80543fb6ebccf64d0bcbe91a2e97873886164c Mon Sep 17 00:00:00 2001 From: tangbinzy Date: Thu, 16 Mar 2023 07:03:51 +0000 Subject: [PATCH] esx: call freeaddrinfo earlier in esxUtil_ResolveHostname 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 Reviewed-by: Laine Stump Signed-off-by: tangbin (cherry-pick from 3aaf23ff69cea9abb7b7a43d9ff3eb687a916a2e) --- src/esx/esx_util.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index 89d136248f..98ce462ff0 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -311,17 +311,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; } -- 2.27.0