From 3ff453aaa03aa348271797c7e4e13dd9cdc339d2 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 2 Aug 2017 12:57:02 -0700 Subject: [PATCH] Make sure freeaddrinfo is always called on failure. Bug: https://android-review.googlesource.com/#/c/platform/system/core/+/268797/2/libcutils/socket_network_client_unix.c Test: builds Signed-off-by: Ivan Maidanski Change-Id: I2d93c8359c3398769d408284f77d56e09713a7f3 --- libcutils/socket_network_client_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcutils/socket_network_client_unix.c b/libcutils/socket_network_client_unix.c index 37851b17a..1b87c49be 100644 --- a/libcutils/socket_network_client_unix.c +++ b/libcutils/socket_network_client_unix.c @@ -63,7 +63,7 @@ int socket_network_client_timeout(const char* host, int port, int type, int time for (struct addrinfo* addr = addrs; addr != NULL; addr = addr->ai_next) { // The Mac doesn't have SOCK_NONBLOCK. int s = socket(addr->ai_family, type, addr->ai_protocol); - if (s == -1 || toggle_O_NONBLOCK(s) == -1) return -1; + if (s == -1 || toggle_O_NONBLOCK(s) == -1) break; int rc = connect(s, addr->ai_addr, addr->ai_addrlen); if (rc == 0) {