From f158e35c13fde531634414bf32ed5a32af5ccf38 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Fri, 15 Nov 2019 10:46:24 +0900 Subject: [PATCH] Make variable local to code block --- repmgr-client.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/repmgr-client.c b/repmgr-client.c index 1a292097..34a72802 100644 --- a/repmgr-client.c +++ b/repmgr-client.c @@ -3883,7 +3883,6 @@ check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *fo t_conninfo_param_list follow_target_repl_conninfo = T_CONNINFO_PARAM_LIST_INITIALIZER; PGconn *follow_target_repl_conn = NULL; t_system_identification follow_target_identification = T_SYSTEM_IDENTIFICATION_INITIALIZER; - TimeLineHistoryEntry *follow_target_history = NULL; bool success = true; const char *action = is_rejoin == true ? "rejoin" : "follow"; @@ -4001,7 +4000,8 @@ check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *fo /* * upstream has higher timeline - check where it forked off from this node's timeline */ - follow_target_history = get_timeline_history(follow_target_repl_conn, local_tli + 1); + TimeLineHistoryEntry *follow_target_history = get_timeline_history(follow_target_repl_conn, + local_tli + 1); if (follow_target_history == NULL) { @@ -4065,13 +4065,12 @@ check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *fo format_lsn(follow_target_history->end)); } } + + pfree(follow_target_history); } PQfinish(follow_target_repl_conn); - if (follow_target_history) - pfree(follow_target_history); - return success; }