Skip to content

Commit 04b8601

Browse files
committed
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
1 parent 18452b7 commit 04b8601

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/bin/pg_dump/compress_zstd.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,10 @@ EndCompressorZstd(ArchiveHandle *AH, CompressorState *cs)
137137
Assert(zstdcs->dstream == NULL);
138138
_ZstdWriteCommon(AH, cs, true);
139139
ZSTD_freeCStream(zstdcs->cstream);
140-
pg_free(zstdcs->output.dst);
141140
}
142141

142+
/* output buffer may be allocated in either mode */
143+
pg_free(zstdcs->output.dst);
143144
pg_free(zstdcs);
144145
}
145146

0 commit comments

Comments
 (0)