Commit 35ca6700 authored by shenlongxing's avatar shenlongxing
Browse files

Fix cluster-announce-ip memory leak

parent fd174cca
...@@ -3325,10 +3325,11 @@ void clusterCron(void) { ...@@ -3325,10 +3325,11 @@ void clusterCron(void) {
if (prev_ip && curr_ip && strcmp(prev_ip,curr_ip)) changed = 1; if (prev_ip && curr_ip && strcmp(prev_ip,curr_ip)) changed = 1;
if (changed) { if (changed) {
prev_ip = curr_ip; if (prev_ip) zfree(prev_ip);
if (prev_ip) prev_ip = zstrdup(prev_ip);
prev_ip = curr_ip;
if (curr_ip) { if (curr_ip) {
prev_ip = zstrdup(prev_ip);
strncpy(myself->ip,server.cluster_announce_ip,NET_IP_STR_LEN); strncpy(myself->ip,server.cluster_announce_ip,NET_IP_STR_LEN);
myself->ip[NET_IP_STR_LEN-1] = '\0'; myself->ip[NET_IP_STR_LEN-1] = '\0';
} else { } else {
......
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