Fix some file descriptor leaks. Closes PR# 2392.

2.2 candidate.
This commit is contained in:
mpp 1997-01-09 14:50:42 +00:00
parent 7184681fc2
commit cbe97b6291
2 changed files with 16 additions and 12 deletions

View File

@ -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;

View File

@ -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;