* mandoc: Invalidate the tag_files.tfd after fclose(3)ing the stram
@ 2018-02-23 16:47 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2018-02-23 16:47 UTC (permalink / raw)
To: source
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-02-23 16:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-23 16:47 mandoc: Invalidate the tag_files.tfd after fclose(3)ing the stram schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).