Skip to content

Commit

Permalink
Fix some double free bugs
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Murphy <[email protected]>
  • Loading branch information
murphyjacob4 committed Nov 2, 2024
1 parent 2cac076 commit d0b6bf3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -3878,6 +3878,7 @@ void freeReplicationLink(replicationLink *link) {
* replicationHandlePrimaryDisconnection which can trigger a re-connect
* directly from within that call. */
sdsfree(link->host);
link->host = NULL;
if (link->client) {
freeClient(link->client);
link->client = NULL;
Expand Down Expand Up @@ -4380,7 +4381,10 @@ void replicationResurrectCachedPrimary(replicationLink *link) {
serverAssert(link == server.primary_replication_link);
link->client = server.cached_primary;
server.cached_primary = NULL;

/* The client takes ownership of the connection now. */
link->client->conn = link->transfer_s;
link->transfer_s = NULL;

establishSourceConnection(link);
/* Re-add to the list of clients. */
Expand Down

0 comments on commit d0b6bf3

Please sign in to comment.