Skip to content

Commit

Permalink
Fix memory leak unsetting master
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnSully committed Apr 11, 2019
1 parent 715de15 commit e951386
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/replication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e951386

Please sign in to comment.