aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2020-04-17 10:45:20 +0900
committerMichael Paquier <michael@paquier.xyz>2020-04-17 10:45:20 +0900
commit213e2b7363cd068b9c4481353c3b72729c069b97 (patch)
tree7698c393b9568a548b1b686afaff82eb2f020141 /src
parentcc2737ab03128fb0bc46af6c63289f6bea07068c (diff)
downloadpostgresql-213e2b7363cd068b9c4481353c3b72729c069b97.tar.gz
postgresql-213e2b7363cd068b9c4481353c3b72729c069b97.zip
Fix minor memory leak in pg_basebackup and pg_receivewal
The result of the query used to retrieve the WAL segment size from the backend was not getting freed in two code paths. Both pg_basebackup and pg_receivewal exit immediately if a failure happened on this query, so this was not an actual problem, but it could be an issue if this code gets used for other tools in different ways, be they future tools in this code tree or external, existing, ones. Oversight in commit fc49e24, so backpatch down to 11. Author: Jie Zhang Discussion: https://postgr.es/m/970ad9508461469b9450b64027842331@G08CNEXMBPEKD06.g08.fujitsu.local Backpatch-through: 11
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_basebackup/streamutil.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c
index 52f1e559b74..e9a2739f8e2 100644
--- a/src/bin/pg_basebackup/streamutil.c
+++ b/src/bin/pg_basebackup/streamutil.c
@@ -321,9 +321,12 @@ RetrieveWalSegSize(PGconn *conn)
{
fprintf(stderr, _("%s: WAL segment size could not be parsed\n"),
progname);
+ PQclear(res);
return false;
}
+ PQclear(res);
+
/* set the multiplier based on unit to convert xlog_val to bytes */
if (strcmp(xlog_unit, "MB") == 0)
multiplier = 1024 * 1024;
@@ -343,7 +346,6 @@ RetrieveWalSegSize(PGconn *conn)
return false;
}
- PQclear(res);
return true;
}