summaryrefslogtreecommitdiff
path: root/src/bin/pg_basebackup/receivelog.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2021-07-26 11:14:21 +0900
committerMichael Paquier <michael@paquier.xyz>2021-07-26 11:14:21 +0900
commit4372f0685de164e769e895dbada18cad792192b2 (patch)
treea912df2b6fa1ae885beef37f1ceec51eeaaa525a /src/bin/pg_basebackup/receivelog.c
parent710fabfa2e4ec88a357dc36209547948545414c9 (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 1e5c669bafe..e71cbfe58b1 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)
fprintf(stderr,
_("%s: could not get size of write-ahead log file \"%s\": %s\n"),
progname, fn, stream->walmethod->getlasterror());
+ pg_free(fn);
return false;
}
if (size == XLogSegSize)
@@ -132,6 +133,7 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
fprintf(stderr,
_("%s: could not open existing write-ahead log file \"%s\": %s\n"),
progname, fn, stream->walmethod->getlasterror());
+ pg_free(fn);
return false;
}
@@ -141,11 +143,13 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
fprintf(stderr,
_("%s: could not fsync existing write-ahead log file \"%s\": %s\n"),
progname, 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)
@@ -158,6 +162,7 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
"%s: write-ahead log file \"%s\" has %d bytes, should be 0 or %d\n",
size),
progname, fn, (int) size, XLogSegSize);
+ pg_free(fn);
return false;
}
/* File existed and was empty, so fall through and open */
@@ -171,9 +176,11 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
fprintf(stderr,
_("%s: could not open write-ahead log file \"%s\": %s\n"),
progname, fn, stream->walmethod->getlasterror());
+ pg_free(fn);
return false;
}
+ pg_free(fn);
walfile = f;
return true;
}