Signed-off-by: Chen Fan <chen.fan.fnst@xxxxxxxxxxxxxx> --- src/util/virsocketaddr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 8c9f05f..5f54e68 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -894,19 +894,24 @@ virSocketAddrIsNumericLocalhost(const char *addr) struct in_addr tmp = { .s_addr = htonl(INADDR_LOOPBACK) }; struct sockaddr_in *inet4; struct sockaddr_in6 *inet6; + bool ret = false; if (virSocketAddrParseInternal(&res, addr, AF_UNSPEC, false) < 0) - return false; + return ret; switch (res->ai_addr->sa_family) { case AF_INET: inet4 = (struct sockaddr_in*) res->ai_addr; - return memcmp(&inet4->sin_addr.s_addr, &tmp.s_addr, - sizeof(inet4->sin_addr.s_addr)) == 0; + ret = memcmp(&inet4->sin_addr.s_addr, &tmp.s_addr, + sizeof(inet4->sin_addr.s_addr)) == 0; + break; case AF_INET6: inet6 = (struct sockaddr_in6*) res->ai_addr; - return IN6_IS_ADDR_LOOPBACK(&(inet6->sin6_addr)); + ret = IN6_IS_ADDR_LOOPBACK(&(inet6->sin6_addr)); + break; } - return false; + + freeaddrinfo(res); + return ret; } -- 1.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list