Subject: kern/3120: memory leak in libsa/ufs.c
To: None <gnats-bugs@gnats.netbsd.org>
From: Matthias Drochner <drochner@zelz26.zel.kfa-juelich.de>
List: netbsd-bugs
Date: 01/17/1997 18:36:53
>Number:         3120
>Category:       kern
>Synopsis:       memory leak in libsa/ufs.c
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 17 10:20:01 1997
>Last-Modified:
>Originator:     Matthias Drochner
>Organization:
	KFA Juelich
>Release:        1.2
>Environment:
	Netbsd-current / libsa
System: NetBSD zelz26 1.2 NetBSD 1.2 (TULIP) #21: Thu Nov 14 22:05:19 MET 1996 drochner@zelz28:/home/drochner/netbsd/sys/arch/i386/compile/TULIP i386


>Description:
	A temporary buffer is not freed if an error occurs in
	the open() function (eg, file not found).
>How-To-Repeat:
	???
>Fix:
*** 554,560 ****
  out:
  	if (buf)
  		free(buf, fs->fs_bsize);
! 	if (rc) {
  		free(fp->f_fs, SBSIZE);
  		free(fp, sizeof(struct file));
  	}
--- 554,562 ----
  out:
  	if (buf)
  		free(buf, fs->fs_bsize);
!         if (rc) {
! 	        if(fp->f_buf)
! 	                free(fp->f_buf, fp->f_fs->fs_bsize);
  		free(fp->f_fs, SBSIZE);
  		free(fp, sizeof(struct file));
  	}

>Audit-Trail:
>Unformatted: