From e9513862658f485cb15967b7962c0281ed95f53f Mon Sep 17 00:00:00 2001 From: John Sully Date: Thu, 11 Apr 2019 19:55:08 -0400 Subject: [PATCH] Fix memory leak unsetting master --- src/replication.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/replication.cpp b/src/replication.cpp index c062c312c..e46d96d42 100644 --- a/src/replication.cpp +++ b/src/replication.cpp @@ -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