mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
cluster: fix node connection memory leak
Cluster leaks memory while connecting due to missing freeaddrinfo() (Commit modified by @antirez. The freeaddrinfo() call was misplaced so in case of no address was bound, the memory leak was still there). Closes #1801
This commit is contained in:
parent
05676c5d16
commit
1a5e5b6bd4
@ -262,7 +262,8 @@ static int anetTcpGenericConnect(char *err, char *addr, int port,
|
|||||||
if (source_addr) {
|
if (source_addr) {
|
||||||
int bound = 0;
|
int bound = 0;
|
||||||
/* Using getaddrinfo saves us from self-determining IPv4 vs IPv6 */
|
/* Using getaddrinfo saves us from self-determining IPv4 vs IPv6 */
|
||||||
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 end;
|
||||||
}
|
}
|
||||||
@ -272,6 +273,7 @@ static int anetTcpGenericConnect(char *err, char *addr, int port,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
freeaddrinfo(bservinfo);
|
||||||
if (!bound) {
|
if (!bound) {
|
||||||
anetSetError(err, "bind: %s", strerror(errno));
|
anetSetError(err, "bind: %s", strerror(errno));
|
||||||
goto end;
|
goto end;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user