Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20261118125553.9133-19-ilt@envs.net>
Date: Wed, 18 Nov 2026 15:50:00 +0300
From: illiliti <ilt@...s.net>
To: musl@...ts.openwall.com
Cc: illiliti <ilt@...s.net>
Subject: [PATCH v1 18/18] fts: backport memory leak fix from FreeBSD

freebsd src commit: ccdcef45ea7587b77198e50c3e9d11f80e9378f0

Dan Krejsa reports a potential memory leak in an fts_build error case,
detected by Coverity.  (It doesn't seem to show up in Coverity Scan, so I
don't have a CID to point to.)

I don't know whether it is actually possible to arrive in this case with a
non-empty 'head' list.  The cost is low, though.  One additional branch in a
terminal error case isn't the end of the world.
---
 src/misc/fts.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/misc/fts.c b/src/misc/fts.c
index 9e682f38..70567129 100644
--- a/src/misc/fts.c
+++ b/src/misc/fts.c
@@ -790,6 +790,7 @@ mem1:				saved_errno = errno;
 	    (cur->fts_level == FTS_ROOTLEVEL ?
 	    FCHDIR(sp, sp->fts_rfd) :
 	    fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) {
+		fts_lfree(head);
 		cur->fts_info = FTS_ERR;
 		SET(FTS_STOP);
 		return (NULL);
-- 
2.55.0

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.