aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2024-12-17 22:31:26 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2024-12-17 22:31:26 -0500
commit04b86019818067b32ce51883a3322f875d573d15 (patch)
tree916e51db2f52287795009c76d027b4183ed1f3ed
parent18452b70acee293d709f475c4551b3b242d4abd1 (diff)
downloadpostgresql-04b86019818067b32ce51883a3322f875d573d15.tar.gz
postgresql-04b86019818067b32ce51883a3322f875d573d15.zip
Fix memory leak in pg_restore with zstd-compressed data.
EndCompressorZstd() neglected to free everything. This was most visible with a lot of large objects in the dump. Per report from Tomasz Szypowski. Back-patch to v16 where this code came in. Discussion: https://postgr.es/m/DU0PR04MB94193D038A128EF989F922D199042@DU0PR04MB9419.eurprd04.prod.outlook.com
-rw-r--r--src/bin/pg_dump/compress_zstd.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/bin/pg_dump/compress_zstd.c b/src/bin/pg_dump/compress_zstd.c
index aa5aff2fee3..02987d6b0ba 100644
--- a/src/bin/pg_dump/compress_zstd.c
+++ b/src/bin/pg_dump/compress_zstd.c
@@ -137,9 +137,10 @@ EndCompressorZstd(ArchiveHandle *AH, CompressorState *cs)
Assert(zstdcs->dstream == NULL);
_ZstdWriteCommon(AH, cs, true);
ZSTD_freeCStream(zstdcs->cstream);
- pg_free(zstdcs->output.dst);
}
+ /* output buffer may be allocated in either mode */
+ pg_free(zstdcs->output.dst);
pg_free(zstdcs);
}