diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-05-05 16:20:12 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-05-05 16:20:12 +0300 |
commit | 329de9fa983debc941ebd79f335f2574b72a3694 (patch) | |
tree | ae62279bbfbb787a356c4b9ca4a368ed371b5c9d /src | |
parent | c83457683968e2263d7e6bcdcdd52d472f9b0f8d (diff) | |
download | postgresql-329de9fa983debc941ebd79f335f2574b72a3694.tar.gz postgresql-329de9fa983debc941ebd79f335f2574b72a3694.zip |
Don't leak memory after connection aborts in pg_recvlogical.
Andres Freund, noticed by coverity.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_basebackup/pg_recvlogical.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c index 8141ba31f9d..fe902cf9691 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; |