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

anetTcpGenericConnect(), jump to error not end on error

Two code paths jumped to the "ok, return the socket to the user" code
path to handle error conditions.

Related to issues #2609 and #2612.
parent a401a84e
...@@ -295,7 +295,7 @@ static int anetTcpGenericConnect(char *err, char *addr, int port, ...@@ -295,7 +295,7 @@ static int anetTcpGenericConnect(char *err, char *addr, int port,
if ((rv = getaddrinfo(source_addr, NULL, &hints, &bservinfo)) != 0) if ((rv = getaddrinfo(source_addr, NULL, &hints, &bservinfo)) != 0)
{ {
anetSetError(err, "%s", gai_strerror(rv)); anetSetError(err, "%s", gai_strerror(rv));
goto end; goto error;
} }
for (b = bservinfo; b != NULL; b = b->ai_next) { for (b = bservinfo; b != NULL; b = b->ai_next) {
if (bind(s,b->ai_addr,b->ai_addrlen) != -1) { if (bind(s,b->ai_addr,b->ai_addrlen) != -1) {
...@@ -306,7 +306,7 @@ static int anetTcpGenericConnect(char *err, char *addr, int port, ...@@ -306,7 +306,7 @@ static int anetTcpGenericConnect(char *err, char *addr, int port,
freeaddrinfo(bservinfo); freeaddrinfo(bservinfo);
if (!bound) { if (!bound) {
anetSetError(err, "bind: %s", strerror(errno)); anetSetError(err, "bind: %s", strerror(errno));
goto end; goto error;
} }
} }
if (connect(s,p->ai_addr,p->ai_addrlen) == -1) { if (connect(s,p->ai_addr,p->ai_addrlen) == -1) {
......
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