Jianghua Yang <yjhjstz@gmail.com> writes:
> == The Bug ==
> All four compression open functions use this pattern when an existing
> file descriptor is passed in:
> if (fd >= 0)
> fp = fdopen(dup(fd), mode); /* or gzdopen() */
> if (fp == NULL)
> return false; /* dup'd fd is leaked here */
> The problem is that dup(fd) and fdopen()/gzdopen() are two separate
> steps, and their failure modes must be handled independently:
Hmm. You're right that we could leak the dup'd FD, but would it matter?
I'm pretty sure all these programs will just exit immediately on
failure.
I'm not averse to improving the code, but I'm not sure there is
a live bug worth back-patching.
regards, tom lane