mirror of
https://github.com/postgres/postgres.git
synced 2025-05-21 15:54:08 +03:00
Fix unchecked return value from strdup
The pg_dump compression was using strdup() instead of pg_strdup() and failed to check the returned pointer for out-of-memory before dereferencing it. Fix by using pg_strdup() instead which probably was the intention here in the original patch. Backpatch to v16 where pg_dump compression was introduced. Reviewed-by: Tristan Partin <tristan@neon.tech> Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Discussion: https://postgr.es/m/CC661D60-6F4C-474D-B9CF-E789ACA3CEFC@yesql.se Backpatch-through: 16
This commit is contained in:
parent
94415b04ed
commit
5b5db413d2
@ -249,7 +249,7 @@ InitDiscoverCompressFileHandle(const char *path, const char *mode)
|
|||||||
|
|
||||||
Assert(strcmp(mode, PG_BINARY_R) == 0);
|
Assert(strcmp(mode, PG_BINARY_R) == 0);
|
||||||
|
|
||||||
fname = strdup(path);
|
fname = pg_strdup(path);
|
||||||
|
|
||||||
if (hasSuffix(fname, ".gz"))
|
if (hasSuffix(fname, ".gz"))
|
||||||
compression_spec.algorithm = PG_COMPRESSION_GZIP;
|
compression_spec.algorithm = PG_COMPRESSION_GZIP;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user