diff options
author | Michael Paquier <michael@paquier.xyz> | 2021-07-26 11:13:37 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2021-07-26 11:13:37 +0900 |
commit | 4ef64c425dbcda151c9f163aadff982343808e09 (patch) | |
tree | 6f715b4bdb9429e8d21b11b1d2522fd885fe9ff2 /src/bin/pg_basebackup/receivelog.c | |
parent | 28d936031a86d94806c6604480ff3f3f169b371c (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.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index 7af90093207..44cb5b36611 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -117,6 +117,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) @@ -127,6 +128,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; } @@ -140,6 +142,7 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint) } walfile = f; + pg_free(fn); return true; } if (size != 0) @@ -151,6 +154,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 */ @@ -164,9 +168,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; } |