>From c41faf9047e0d133b0cc233e6d7ca0be4e54e589 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Wed, 30 Apr 2014 17:29:04 +0200 Subject: [PATCH 3/4] Don't leak memory after connection aborts in pg_recvlogical. Noticed by coverity. --- src/bin/pg_basebackup/pg_recvlogical.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c index 8141ba3..fe902cf 100644 --- a/src/bin/pg_basebackup/pg_recvlogical.c +++ b/src/bin/pg_basebackup/pg_recvlogical.c @@ -547,9 +547,6 @@ StreamLog(void) } PQclear(res); - if (copybuf != NULL) - PQfreemem(copybuf); - if (outfd != -1 && strcmp(outfile, "-") != 0) { int64 t = feGetCurrentTimestamp(); @@ -563,6 +560,11 @@ StreamLog(void) } outfd = -1; error: + if (copybuf != NULL) + { + PQfreemem(copybuf); + copybuf = NULL; + } destroyPQExpBuffer(query); PQfinish(conn); conn = NULL; -- 1.8.3.251.g1462b67