Fix memory leak unsetting master

Former-commit-id: acdc4fdfec93c9121bdc12e52a9cd57f494f8dcd
This commit is contained in:
John Sully 2019-04-11 19:55:08 -04:00
parent 92feaf280f
commit 89e09dd609

View File

@ -2263,6 +2263,13 @@ struct redisMaster *replicationAddMaster(char *ip, int port) {
return mi;
}
void freeMasterInfo(redisMaster *mi)
{
zfree(mi->masterauth);
zfree(mi->masteruser);
zfree(mi);
}
/* Cancel replication, setting the instance as a master itself. */
void replicationUnsetMaster(redisMaster *mi) {
serverAssert(mi->masterhost != NULL);
@ -2305,6 +2312,7 @@ void replicationUnsetMaster(redisMaster *mi) {
listNode *ln = listSearchKey(server.masters, mi);
serverAssert(ln != nullptr);
listDelNode(server.masters, ln);
freeMasterInfo(mi);
}
/* This function is called when the slave lose the connection with the