Fix #3848 by closing the descriptor on error.

This commit is contained in:
antirez 2017-04-18 16:24:06 +02:00
parent 8b7b4d6734
commit 02d02a3754

View File

@ -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);