Code in clusterCron function (cluster.c)
if (changed) {
prev_ip = curr_ip; ## // Is this will be Memory leak ??
if (prev_ip) prev_ip = zstrdup(prev_ip);
if (curr_ip) {
strncpy(myself->ip,server.cluster_announce_ip,NET_IP_STR_LEN);
myself->ip[NET_IP_STR_LEN-1] = '\0';
} else {
myself->ip[0] = '\0'; /* Force autodetection. */
}
}
Comment From: badboy
The value prev_ip points to is dynamically allocated. prev_ip is assigned the return value of strdup, which mallocs and copies the other value.
So this indeed looks like it would leak memory if the user changes the cluster announce IP via CONFIG SET. That's about 15 bytes per CONFIG SET, so not critical but could still be fixed.
cc @antirez
Comment From: jonasmao
argree with @badboy
Comment From: hwware
hi @jonasmao , thanks for reporting, this issue should be fixed by https://github.com/redis/redis/pull/5191, @oranagra suggest to close..