diff --git a/src/bin/pg_dump/compress_none.c b/src/bin/pg_dump/compress_none.c index 06c400424a..1f71e47a1c 100644 --- a/src/bin/pg_dump/compress_none.c +++ b/src/bin/pg_dump/compress_none.c @@ -171,7 +171,15 @@ open_none(const char *path, int fd, const char *mode, CompressFileHandle *CFH) Assert(CFH->private_data == NULL); if (fd >= 0) - CFH->private_data = fdopen(dup(fd), mode); + { + int thisfd; + + thisfd = dup(fd); + if (thisfd < 0) + pg_fatal("could not duplicate file: %m"); + + CFH->private_data = fdopen(thisfd, mode); + } else CFH->private_data = fopen(path, mode);