Commit 8d44c52a authored by antirez's avatar antirez
Browse files

Fix #3848 by closing the descriptor on error.

parent 5c107c62
...@@ -464,7 +464,7 @@ static int anetV6Only(char *err, int s) { ...@@ -464,7 +464,7 @@ static int anetV6Only(char *err, int s) {
static int _anetTcpServer(char *err, int port, char *bindaddr, int af, int backlog) 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") */ char _port[6]; /* strlen("65535") */
struct addrinfo hints, *servinfo, *p; struct addrinfo hints, *servinfo, *p;
...@@ -493,6 +493,7 @@ static int _anetTcpServer(char *err, int port, char *bindaddr, int af, int backl ...@@ -493,6 +493,7 @@ static int _anetTcpServer(char *err, int port, char *bindaddr, int af, int backl
} }
error: error:
if (s != -1) close(s);
s = ANET_ERR; s = ANET_ERR;
end: end:
freeaddrinfo(servinfo); freeaddrinfo(servinfo);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment