diff options
author | mpp <mpp@FreeBSD.org> | 1997-01-09 14:50:42 +0000 |
---|---|---|
committer | mpp <mpp@FreeBSD.org> | 1997-01-09 14:50:42 +0000 |
commit | cbe97b6291cb368fe7dcebfa54de8986bfebfc59 (patch) | |
tree | de60edff8d863ba64ab90633e827a9e88fae6c98 /gnu/usr.bin | |
parent | 7184681fc2ce55301db89d61cb3a78462e7b8e4c (diff) | |
download | FreeBSD-src-cbe97b6291cb368fe7dcebfa54de8986bfebfc59.zip FreeBSD-src-cbe97b6291cb368fe7dcebfa54de8986bfebfc59.tar.gz |
Fix some file descriptor leaks. Closes PR# 2392.
2.2 candidate.
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r-- | gnu/usr.bin/man/man/man.c | 11 | ||||
-rw-r--r-- | gnu/usr.bin/man/man/manpath.c | 17 |
2 files changed, 16 insertions, 12 deletions
diff --git a/gnu/usr.bin/man/man/man.c b/gnu/usr.bin/man/man/man.c index fdfab5a..4452fc4 100644 --- a/gnu/usr.bin/man/man/man.c +++ b/gnu/usr.bin/man/man/man.c @@ -757,12 +757,12 @@ ultimate_source (name, path) next: if ((fp = fopen (ult, "r")) == NULL) - return buf; - - if (fgets (buf, BUFSIZ, fp) == NULL) return ult; - if (strlen (buf) < 5) + end = fgets (buf, BUFSIZ, fp); + fclose(fp); + + if (!end || strlen (buf) < 5) return ult; beg = buf; @@ -948,6 +948,7 @@ make_roff_command (file) { cp = line; fgets (line, BUFSIZ, fp); + fclose(fp); if (*cp++ == '\'' && *cp++ == '\\' && *cp++ == '"' && *cp++ == ' ') { if (debug) @@ -955,8 +956,6 @@ make_roff_command (file) status = parse_roff_directive (cp, file, buf, sizeof(buf)); - fclose (fp); - if (status == 0) return buf; diff --git a/gnu/usr.bin/man/man/manpath.c b/gnu/usr.bin/man/man/manpath.c index 294ffaf..cdc370c 100644 --- a/gnu/usr.bin/man/man/manpath.c +++ b/gnu/usr.bin/man/man/manpath.c @@ -202,9 +202,11 @@ get_dirlist () if (!strncmp ("MANDATORY_MANPATH", bp, 17)) { - if ((p = strchr (bp, ' ')) == NULL) - if ((p = strchr (bp, '\t')) == NULL) - return -1; + if ((p = strchr (bp, ' ')) == NULL && + (p = strchr (bp, '\t')) == NULL) { + fclose(config); + return -1; + } bp = p; @@ -224,9 +226,11 @@ get_dirlist () } else if (!strncmp ("MANPATH_MAP", bp, 11)) { - if ((p = strchr (bp, ' ')) == NULL) - if ((p = strchr (bp, '\t')) == NULL) - return -1; + if ((p = strchr (bp, ' ')) == NULL && + (p = strchr (bp, '\t')) == NULL) { + fclose(config); + return -1; + } bp = p; @@ -259,6 +263,7 @@ get_dirlist () dlp++; } + fclose(config); dlp->bin[0] = '\0'; dlp->mandir[0] = '\0'; dlp->mandatory = 0; |