From nobody@FreeBSD.org  Sun May 30 13:29:15 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id B2CB416A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 30 May 2004 13:29:15 -0700 (PDT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id AC6A243D5D
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 30 May 2004 13:29:15 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i4UKTFmP010073
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 30 May 2004 13:29:15 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.11/8.12.11/Submit) id i4UKTFiE010072;
	Sun, 30 May 2004 13:29:15 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200405302029.i4UKTFiE010072@www.freebsd.org>
Date: Sun, 30 May 2004 13:29:15 -0700 (PDT)
From: Matthew Emmerton <matt@gsicomp.on.ca>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Small memory leak in ls
X-Send-Pr-Version: www-2.3

>Number:         67392
>Category:       bin
>Synopsis:       Small memory leak in ls
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    le
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 30 13:30:25 PDT 2004
>Closed-Date:    Wed Jun 09 11:24:38 GMT 2004
>Last-Modified:  Wed Jun 09 11:24:38 GMT 2004
>Originator:     Matthew Emmerton
>Release:        4.9-STABLE
>Organization:
GSI Computer Service
>Environment:
FreeBSD penelope.gsicomp.on.ca 4.9-STABLE FreeBSD 4.9-STABLE #3: Fri May  7 22:16:53 EDT 2004     root@penelope.gsicomp.on.ca:/usr/obj/usr/src/sys/PENELOPE.20040505.01  i386
      
>Description:
There is a tiny memory leak in 'ls'.

If the LS_COLWIDTHS environment variable is defined, then a small memory buffer is malloc()'d to build up a temporary string which is then passed to sscanf().

However, this memory buffer is never freed.
>How-To-Repeat:
I haven't been able to find a test case that causes the memory leak to impact the system.

>Fix:
--- bin/ls/ls.c.orig    Sun May 30 16:34:54 2004
+++ bin/ls/ls.c Sun May 30 16:35:06 2004
@@ -597,6 +597,7 @@
                maxblock = makenines(maxblock);
                maxnlink = makenines(maxnlink);
                maxsize = makenines(maxsize);
+               free(jinitmax);
        }
        bcfile = 0;
        flags = NULL;

>Release-Note:
>Audit-Trail:

From: Edwin Groothuis <edwin@mavetju.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/67392: Small memory leak in ls
Date: Mon, 31 May 2004 09:24:48 +1000

 On Sun, May 30, 2004 at 01:29:15PM -0700, Matthew Emmerton wrote:
 > --- bin/ls/ls.c.orig    Sun May 30 16:34:54 2004
 > +++ bin/ls/ls.c Sun May 30 16:35:06 2004
 
 That's line 627 in ls.c on 5.2.1
 
 Edwin
 
 -- 
 Edwin Groothuis      |            Personal website: http://www.mavetju.org
 edwin@mavetju.org    |          Weblog: http://weblog.barnet.com.au/edwin/
Responsible-Changed-From-To: freebsd-bugs->le 
Responsible-Changed-By: le 
Responsible-Changed-When: Thu Jun 3 07:47:48 PDT 2004 
Responsible-Changed-Why:  
I'll handle this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=67392 
State-Changed-From-To: open->patched 
State-Changed-By: le 
State-Changed-When: Thu Jun 3 08:04:27 PDT 2004 
State-Changed-Why:  
Patch committed, thank you.  Will MFC in 1 week. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=67392 
State-Changed-From-To: patched->closed 
State-Changed-By: le 
State-Changed-When: Wed Jun 9 11:24:25 GMT 2004 
State-Changed-Why:  
MFC done. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=67392 
>Unformatted:
