From faddaed316cb39b64bc87dc166ba712c5f1639c3 Mon Sep 17 00:00:00 2001 From: Dan Farina Date: Wed, 22 Dec 2010 15:01:35 -0800 Subject: [PATCH] Avoid a use-after-free in verbose logging Previously, this print would use memory freed by PQClear previously. Signed-off-by: Dan Farina --- repmgr.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/repmgr.c b/repmgr.c index 7eaca0f7..b9336011 100644 --- a/repmgr.c +++ b/repmgr.c @@ -974,6 +974,12 @@ stop_backup: return; } last_wal_segment = PQgetvalue(res, 0, 0); + + if (verbose) + printf( + _("%s requires primary to keep WAL files %s until at least %s\n"), + progname, first_wal_segment, last_wal_segment); + PQclear(res); PQfinish(conn); @@ -981,11 +987,6 @@ stop_backup: if (r != 0) return; - if (verbose) - printf( - _("%s requires primary to keep WAL files %s until at least %s\n"), - progname, first_wal_segment, last_wal_segment); - /* * We need to create the pg_xlog sub directory too, I'm reusing a variable * here.