From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 3aa3addb for ; Fri, 23 Feb 2018 11:47:40 -0500 (EST) Date: Fri, 23 Feb 2018 11:47:40 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: Invalidate the tag_files.tfd after fclose(3)ing the stram X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-Id: <84f4c45ed345292c@fantadrom.bsd.lv> Log Message: ----------- Invalidate the tag_files.tfd after fclose(3)ing the stram associated with it. In main() assert that the tfd was actually invalidated. This avoids closing an invalid fd. >From tb@; OK deraadt@ on an earlier version. Modified Files: -------------- mandoc: main.c tag.c Revision Data ------------- Index: tag.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/tag.c,v retrieving revision 1.18 retrieving revision 1.19 diff -Ltag.c -Ltag.c -u -p -r1.18 -r1.19 --- tag.c +++ tag.c @@ -213,6 +213,9 @@ tag_write(void) ohash_delete(&tag_data); if (stream != NULL) fclose(stream); + else + close(tag_files.tfd); + tag_files.tfd = -1; } void Index: main.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/main.c,v retrieving revision 1.302 retrieving revision 1.303 diff -Lmain.c -Lmain.c -u -p -r1.302 -r1.303 --- main.c +++ main.c @@ -1184,7 +1184,7 @@ spawn_pager(struct tag_files *tag_files) if (dup2(tag_files->ofd, STDOUT_FILENO) == -1) err((int)MANDOCLEVEL_SYSERR, "pager stdout"); close(tag_files->ofd); - close(tag_files->tfd); + assert(tag_files->tfd == -1); /* Do not start the pager before controlling the terminal. */ -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv