diff --git a/src/anet.c b/src/anet.c index 993615601..53a56b0d2 100644 --- a/src/anet.c +++ b/src/anet.c @@ -464,7 +464,7 @@ static int anetV6Only(char *err, int s) { static int _anetTcpServer(char *err, int port, char *bindaddr, int af, int backlog) { - int s, rv; + int s = -1, rv; char _port[6]; /* strlen("65535") */ struct addrinfo hints, *servinfo, *p; @@ -493,6 +493,7 @@ static int _anetTcpServer(char *err, int port, char *bindaddr, int af, int backl } error: + if (s != -1) close(s); s = ANET_ERR; end: freeaddrinfo(servinfo);