diff options
author | shenlongxing <shenlongxing2012@gmail.com> | 2018-07-31 16:01:44 +0800 |
---|---|---|
committer | shenlongxing <shenlongxing2012@gmail.com> | 2018-07-31 16:01:44 +0800 |
commit | 35ca6700600f2b1991e71e6196ec03ba4bad997f (patch) | |
tree | 7e0ce10be681ccd6d237cc399e468d2ea7d63a99 /src/cluster.c | |
parent | fd174cca23ede115ff71b379f10b407cfb54d3ad (diff) | |
download | redis-35ca6700600f2b1991e71e6196ec03ba4bad997f.tar.gz |
Fix cluster-announce-ip memory leak
Diffstat (limited to 'src/cluster.c')
-rw-r--r-- | src/cluster.c | 5 |
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 { |