summaryrefslogtreecommitdiff
path: root/src/cluster.c
diff options
context:
space:
mode:
authorshenlongxing <shenlongxing2012@gmail.com>2018-07-31 16:01:44 +0800
committershenlongxing <shenlongxing2012@gmail.com>2018-07-31 16:01:44 +0800
commit35ca6700600f2b1991e71e6196ec03ba4bad997f (patch)
tree7e0ce10be681ccd6d237cc399e468d2ea7d63a99 /src/cluster.c
parentfd174cca23ede115ff71b379f10b407cfb54d3ad (diff)
downloadredis-35ca6700600f2b1991e71e6196ec03ba4bad997f.tar.gz
Fix cluster-announce-ip memory leak
Diffstat (limited to 'src/cluster.c')
-rw-r--r--src/cluster.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/cluster.c b/src/cluster.c
index 8b76d9ad0..7a6a5f782 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -3325,10 +3325,11 @@ void clusterCron(void) {
if (prev_ip && curr_ip && strcmp(prev_ip,curr_ip)) changed = 1;
if (changed) {
- prev_ip = curr_ip;
- if (prev_ip) prev_ip = zstrdup(prev_ip);
+ if (prev_ip) zfree(prev_ip);
+ prev_ip = curr_ip;
if (curr_ip) {
+ prev_ip = zstrdup(prev_ip);
strncpy(myself->ip,server.cluster_announce_ip,NET_IP_STR_LEN);
myself->ip[NET_IP_STR_LEN-1] = '\0';
} else {