summaryrefslogtreecommitdiff
path: root/src/anet.c
diff options
context:
space:
mode:
authorkingsumos <kingsumos@users.noreply.github.com>2014-06-09 15:32:27 -0300
committerantirez <antirez@gmail.com>2014-08-07 12:35:03 +0200
commit1a5e5b6bd44eb106dcb7114a8f22dda4b475238d (patch)
treef11b2962e6a17b9668e50784893a7c440e0f0eef /src/anet.c
parent05676c5d1614ad894a1ff77d941b83732739046e (diff)
downloadredis-1a5e5b6bd44eb106dcb7114a8f22dda4b475238d.tar.gz
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
Diffstat (limited to 'src/anet.c')
-rw-r--r--src/anet.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/anet.c b/src/anet.c
index 87cc3ea25..c053ccf88 100644
--- a/src/anet.c
+++ b/src/anet.c
@@ -262,7 +262,8 @@ static int anetTcpGenericConnect(char *err, char *addr, int port,
if (source_addr) {
int bound = 0;
/* 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));
goto end;
}
@@ -272,6 +273,7 @@ static int anetTcpGenericConnect(char *err, char *addr, int port,
break;
}
}
+ freeaddrinfo(bservinfo);
if (!bound) {
anetSetError(err, "bind: %s", strerror(errno));
goto end;