summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMukund Sivaraman <muks@banu.com>2009-11-09 11:16:38 +0530
committerMukund Sivaraman <muks@banu.com>2009-11-09 11:16:38 +0530
commitcd834de190324c1e113271d3cd7e0e6b9a63d411 (patch)
treeb25a7e00274995863bf2d071efc6e2493039e4e6 /src
parentc8c9abc669cc0324c4afb35bfae850e98904d7ae (diff)
downloadtinyproxy-cd834de190324c1e113271d3cd7e0e6b9a63d411.tar.gz
tinyproxy-cd834de190324c1e113271d3cd7e0e6b9a63d411.zip
Close listenfd upon errors
Diffstat (limited to '')
-rw-r--r--src/sock.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/sock.c b/src/sock.c
index 184edde..a7bba15 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -195,6 +195,8 @@ int listen_sock (uint16_t port, socklen_t * addrlen)
if (bind (listenfd, rp->ai_addr, rp->ai_addrlen) == 0)
break; /* success */
+
+ close (listenfd);
}
if (rp == NULL) {
@@ -214,6 +216,7 @@ int listen_sock (uint16_t port, socklen_t * addrlen)
"Unable to start listening socket because of %s",
strerror (errno));
+ close (listenfd);
freeaddrinfo (result);
return -1;
}