Bug 204951

Summary: usr/src/bin/sh/mknodes.c:269: 3 * resource leak ?
Product: Base System Reporter: David Binderman <dcb314>
Component: miscAssignee: Jilles Tjoelker <jilles>
Status: Closed FIXED    
Severity: Affects Some People CC: jilles
Priority: --- Flags: jilles: mfc-stable10+
jilles: mfc-stable9-
jilles: mfc-stable8-
Version: CURRENT   
Hardware: Any   
OS: Any   

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