diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index aca1a9e8b1a..ded9b70dc21 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -912,6 +912,7 @@ HandleCopyStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, if (!close_walfile(basedir, partial_suffix)) { /* Error message written in close_walfile() */ + PQclear(res); goto error; } if (PQresultStatus(res) == PGRES_COPY_IN) @@ -921,6 +922,7 @@ HandleCopyStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, fprintf(stderr, _("%s: could not send copy-end packet: %s"), progname, PQerrorMessage(conn)); + PQclear(res); goto error; } res = PQgetResult(conn);