summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2025-10-22 13:38:37 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2025-10-22 13:38:40 -0400
commit9224c3025243a3daeb49fa58b948c6e1fdf99501 (patch)
tree61cdd8fd6ca573e7f70e3bc4f785c502f6f3bd4b
parent4c5e1d0785ce150c3e6c65b009ea56815acbc8cd (diff)
Fix memory leaks in pg_combinebackup/reconstruct.c.
One code path forgot to free the separately-malloc'd filename part of a struct rfile. Another place freed the filename but forgot the struct rfile itself. These seem worth fixing because with a large backup we could be dealing with many files. Coverity found the bug in make_rfile(). I found the other one by manual inspection.
-rw-r--r--src/bin/pg_combinebackup/reconstruct.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/bin/pg_combinebackup/reconstruct.c b/src/bin/pg_combinebackup/reconstruct.c
index 8acaa54ff38..38d8e8a2dc9 100644
--- a/src/bin/pg_combinebackup/reconstruct.c
+++ b/src/bin/pg_combinebackup/reconstruct.c
@@ -370,6 +370,7 @@ reconstruct_from_incremental_file(char *input_filename,
if (s->relative_block_numbers != NULL)
pfree(s->relative_block_numbers);
pg_free(s->filename);
+ pg_free(s);
}
pfree(sourcemap);
pfree(offsetmap);
@@ -517,6 +518,7 @@ make_rfile(char *filename, bool missing_ok)
{
if (missing_ok && errno == ENOENT)
{
+ pg_free(rf->filename);
pg_free(rf);
return NULL;
}