summaryrefslogtreecommitdiffstats
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-01-08 02:13:39 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-01-08 02:13:39 +0000
commitd28fad77486ce53230d4b8b5731e7f06276c2e92 (patch)
tree978f0ff0a675d9c6abde1033cf8cdd0ce705de4f /mandocdb.c
parentfde5c56f70c8c331d28ac290a122dbd46c25a2e5 (diff)
downloadmandoc-d28fad77486ce53230d4b8b5731e7f06276c2e92.tar.gz
It was very surprising that a function called mparse_readfd()
closed the file descriptor passed to it after completing its work, in particular considering the fact that it required its callers to call open(2) or mparse_open() beforehand. Change mparse_readfd() to not call close(2) and change the callers to call close(2) afterwards, more or less bringing open and close to the same level of the code and making review easier. Note that man.cgi(8) already did that, even though it was wrong in the past. Small restructuring suggested by Christos Zoulas (NetBSD).
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/mandocdb.c b/mandocdb.c
index e3768d9f..3b089194 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1146,6 +1146,7 @@ mpages_merge(struct mparse *mp)
*/
if (mlink->dform != FORM_CAT || mlink->fform != FORM_CAT) {
mparse_readfd(mp, fd, mlink->file);
+ close(fd);
mparse_result(mp, &man, &sodest);
}