Fix memory leak in forgotten node ping ext code path (#1574)
When processing a cluster bus PING extension, there is a memory leak when adding a new key to the `nodes_black_list` dict. We now make sure to free the key `sds` if the dict did not take ownership of it. Signed-off-by: Pierre Turin <pieturin@amazon.com>
This commit is contained in:
parent
87cc3d7a71
commit
c9aea6d2d3
@ -2936,6 +2936,10 @@ void clusterProcessPingExtensions(clusterMsg *hdr, clusterLink *link) {
|
||||
if (n && n != myself && !(nodeIsReplica(myself) && myself->replicaof == n)) {
|
||||
sds id = sdsnewlen(forgotten_node_ext->name, CLUSTER_NAMELEN);
|
||||
dictEntry *de = dictAddOrFind(server.cluster->nodes_black_list, id);
|
||||
if (dictGetKey(de) != id) {
|
||||
/* The dict did not take ownership of the id string, so we need to free it. */
|
||||
sdsfree(id);
|
||||
}
|
||||
uint64_t expire = server.unixtime + ntohu64(forgotten_node_ext->ttl);
|
||||
dictSetUnsignedIntegerVal(de, expire);
|
||||
clusterDelNode(n);
|
||||
|
Loading…
x
Reference in New Issue
Block a user