netpbm/netpbm-more-files.patch

19 lines
708 B
Diff

diff --git a/converter/other/pnmtops.c b/converter/other/pnmtops.c
index e393931..93a5156 100644
--- a/converter/other/pnmtops.c
+++ b/converter/other/pnmtops.c
@@ -1994,6 +1994,13 @@ main(int argc, const char * argv[]) {
name = strdup("noname");
else
name = basebasename(cmdline.inputFileName);
+
+ /* This program manages file descriptors in a way that assumes
+ that new files will get file descriptor numbers less than 10,
+ so we close superfluous files now to make sure that's true.
+ */
+ closeAllBut(fileno(ifP), fileno(stdout), fileno(stderr));
+
{
int eof; /* There are no more images in the input file */
unsigned int imageSeq;