From 0a7c7ae7ab4f6b9d5fe6e2a4c9964fa002436cef Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 11 May 2020 13:52:10 +0900 Subject: [PATCH] standby clone: explicitly set closed connection pointers to NULL We omitted to do this with the connections used when checking the system identifier, which means libpq calls by the teardown function using the pointer risk using unallocated memory. Addresses issue reported in GitHub #644. --- repmgr-action-standby.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index 84afa067..9c94482c 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -5481,6 +5481,7 @@ check_source_server() { uint64 test_system_identifier = system_identifier(cell->node_info->conn); PQfinish(cell->node_info->conn); + cell->node_info->conn = NULL; if (test_system_identifier != UNKNOWN_SYSTEM_IDENTIFIER) { @@ -5504,6 +5505,7 @@ check_source_server() else { PQfinish(cell->node_info->conn); + cell->node_info->conn = NULL; } } clear_node_info_list(&all_nodes);