Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 May 2004 13:29:15 -0700 (PDT)
From:      Matthew Emmerton <matt@gsicomp.on.ca>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/67392: Small memory leak in ls
Message-ID:  <200405302029.i4UKTFiE010072@www.freebsd.org>
Resent-Message-ID: <200405302030.i4UKUP8c065968@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         67392
>Category:       bin
>Synopsis:       Small memory leak in ls
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 30 13:30:25 PDT 2004
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405302029.i4UKTFiE010072>