Bug 204951 - usr/src/bin/sh/mknodes.c:269: 3 * resource leak ?
Summary: usr/src/bin/sh/mknodes.c:269: 3 * resource leak ?
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Jilles Tjoelker
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-02 08:16 UTC by David Binderman
Modified: 2015-12-27 18:17 UTC (History)
1 user (show)

See Also:
jilles: mfc-stable10+
jilles: mfc-stable9-
jilles: mfc-stable8-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2015-12-02 08:16:17 UTC
[usr/src/bin/sh/mknodes.c:269]: (error) Resource leak: cfile
[usr/src/bin/sh/mknodes.c:269]: (error) Resource leak: hfile
[usr/src/bin/sh/mknodes.c:269]: (error) Resource leak: patfile

$ egrep "fopen|fclose" usr/src/bin/sh/mknodes.c
	if ((infp = fopen(argv[1], "r")) == NULL)
	if ((patfile = fopen(file, "r")) == NULL)
	if ((hfile = fopen("nodes.h", "w")) == NULL)
	if ((cfile = fopen("nodes.c", "w")) == NULL)
$
Comment 1 Jilles Tjoelker freebsd_committer freebsd_triage 2015-12-20 14:10:25 UTC
This is a valid bug. The practical effect is that the program does not check for errors from fclose() on a file that was written to.
Comment 2 commit-hook freebsd_committer freebsd_triage 2015-12-20 16:40:42 UTC
A commit references this bug:

Author: jilles
Date: Sun Dec 20 16:40:37 UTC 2015
New revision: 292517
URL: https://svnweb.freebsd.org/changeset/base/292517

Log:
  sh/mknodes: Close files and check for errors when writing.

  This is a build tool only and does not affect run time.

  PR:		204951
  MFC after:	1 week

Changes:
  head/bin/sh/mknodes.c
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-12-27 17:54:21 UTC
A commit references this bug:

Author: jilles
Date: Sun Dec 27 17:53:39 UTC 2015
New revision: 292786
URL: https://svnweb.freebsd.org/changeset/base/292786

Log:
  MFC r292517: sh/mknodes: Close files and check for errors when writing.

  This is a build tool only and does not affect run time.

  PR:		204951

Changes:
_U  stable/10/
  stable/10/bin/sh/mknodes.c