From 9c6288993b052b6c3393bd399768d7ebccc1cc7a Mon Sep 17 00:00:00 2001 From: Greg Smith Date: Wed, 23 Feb 2011 07:26:39 -0500 Subject: [PATCH] Fix double free in standby clone --- repmgr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/repmgr.c b/repmgr.c index 7ff975cb..a541faef 100644 --- a/repmgr.c +++ b/repmgr.c @@ -1035,6 +1035,10 @@ stop_backup: log_info(_("%s requires primary to keep WAL files %s until at least %s\n"), progname, first_wal_segment, last_wal_segment); + /* Finished with the database connection now */ + PQclear(res); + PQfinish(conn); + /* * Only free the first_wal_segment since it was copied out of the * pqresult. @@ -1042,9 +1046,6 @@ stop_backup: free(first_wal_segment); first_wal_segment = NULL; - PQclear(res); - PQfinish(conn); - /* If the rsync failed then exit */ if (r != 0) exit(ERR_BAD_RSYNC); @@ -1064,9 +1065,6 @@ stop_backup: /* Finally, write the recovery.conf file */ create_recovery_file(runtime_options.dest_dir, NULL); - PQclear(res); - PQfinish(conn); - /* * We don't start the service yet because we still may want to * move the directory