Avoid a use-after-free in verbose logging

Previously, this print would use memory freed by PQClear previously.

Signed-off-by: Dan Farina <drfarina@acm.org>
This commit is contained in:
Dan Farina
2010-12-22 15:01:35 -08:00
parent 7b0a142075
commit faddaed316

View File

@@ -974,6 +974,12 @@ stop_backup:
return; return;
} }
last_wal_segment = PQgetvalue(res, 0, 0); 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); PQclear(res);
PQfinish(conn); PQfinish(conn);
@@ -981,11 +987,6 @@ stop_backup:
if (r != 0) if (r != 0)
return; 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 * We need to create the pg_xlog sub directory too, I'm reusing a variable
* here. * here.