bin/67392: Small memory leak in ls

Matthew Emmerton matt at
Sun May 30 13:30:26 PDT 2004

>Number:         67392
>Category:       bin
>Synopsis:       Small memory leak in ls
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 30 13:30:25 PDT 2004
>Originator:     Matthew Emmerton
>Release:        4.9-STABLE
GSI Computer Service
FreeBSD 4.9-STABLE FreeBSD 4.9-STABLE #3: Fri May  7 22:16:53 EDT 2004     root at  i386
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.
I haven't been able to find a test case that causes the memory leak to impact the system.

--- 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;


More information about the freebsd-bugs mailing list