From cd834de190324c1e113271d3cd7e0e6b9a63d411 Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Mon, 9 Nov 2009 11:16:38 +0530 Subject: Close listenfd upon errors --- src/sock.c | 3 +++ 1 file changed, 3 insertions(+) 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; } -- cgit v1.2.3