The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=66ff03065defb26bc2cdec5874c0be88343541c8
commit 66ff03065defb26bc2cdec5874c0be88343541c8 Author: Mark Johnston <ma...@freebsd.org> AuthorDate: 2025-01-14 14:20:26 +0000 Commit: Mark Johnston <ma...@freebsd.org> CommitDate: 2025-01-28 16:00:12 +0000 ls: Release resources before returning from traverse() PR: 278476 MFC after: 2 weeks Reported by: valgrind (cherry picked from commit e6c9c463384d11a44af3e5f2cc947fb69f3a1968) --- bin/ls/ls.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 1ad346440f02..51cd45b84d63 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -655,8 +655,10 @@ traverse(int argc, char *argv[], int options) chp = fts_children(ftsp, 0); if (chp != NULL) display(NULL, chp, options); - if (f_listdir) + if (f_listdir) { + fts_close(ftsp); return; + } /* * If not recursing down this tree and don't need stat info, just get @@ -705,6 +707,7 @@ traverse(int argc, char *argv[], int options) } if (errno) err(1, "fts_read"); + fts_close(ftsp); } /*