summaryrefslogtreecommitdiff
path: root/src/bin/pg_basebackup/receivelog.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2021-07-26 11:14:14 +0900
committerMichael Paquier <michael@paquier.xyz>2021-07-26 11:14:14 +0900
commitc4ef3b81b85434b3d2eac8d0cca3a0078898266a (patch)
tree285be002b74792325a2f14974d45bf304367edef /src/bin/pg_basebackup/receivelog.c
parent1bcfda30fb64eb9ed423e0652e02ce04e2dcaad0 (diff)
Fix a couple of memory leaks in src/bin/pg_basebackup/
These have been introduced by 7fbe0c8, and could happen for pg_basebackup and pg_receivewal. Per report from Coverity for the ones in walmethods.c, I have spotted the ones in receivelog.c after more review. Backpatch-through: 10
Diffstat (limited to 'src/bin/pg_basebackup/receivelog.c')
-rw-r--r--src/bin/pg_basebackup/receivelog.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c
index 6d085c24127..de0d9ae0d05 100644
--- a/src/bin/pg_basebackup/receivelog.c
+++ b/src/bin/pg_basebackup/receivelog.c
@@ -121,6 +121,7 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
{
pg_log_error("could not get size of write-ahead log file \"%s\": %s",
fn, stream->walmethod->getlasterror());
+ pg_free(fn);
return false;
}
if (size == WalSegSz)
@@ -131,6 +132,7 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
{
pg_log_error("could not open existing write-ahead log file \"%s\": %s",
fn, stream->walmethod->getlasterror());
+ pg_free(fn);
return false;
}
@@ -139,11 +141,13 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
{
pg_log_error("could not fsync existing write-ahead log file \"%s\": %s",
fn, stream->walmethod->getlasterror());
+ pg_free(fn);
stream->walmethod->close(f, CLOSE_UNLINK);
return false;
}
walfile = f;
+ pg_free(fn);
return true;
}
if (size != 0)
@@ -155,6 +159,7 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
"write-ahead log file \"%s\" has %d bytes, should be 0 or %d",
size),
fn, (int) size, WalSegSz);
+ pg_free(fn);
return false;
}
/* File existed and was empty, so fall through and open */
@@ -168,9 +173,11 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
{
pg_log_error("could not open write-ahead log file \"%s\": %s",
fn, stream->walmethod->getlasterror());
+ pg_free(fn);
return false;
}
+ pg_free(fn);
walfile = f;
return true;
}