aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2025-01-14 14:20:26 +0000
committerMark Johnston <markj@FreeBSD.org>2025-01-28 16:00:12 +0000
commit66ff03065defb26bc2cdec5874c0be88343541c8 (patch)
treeacc5f0150a7e4ea73dfc6a954dd9a209f20a5fda
parentbe53f732663cbe9c1c4f3e7310cfa82bbe32da90 (diff)
ls: Release resources before returning from traverse()
PR: 278476 MFC after: 2 weeks Reported by: valgrind (cherry picked from commit e6c9c463384d11a44af3e5f2cc947fb69f3a1968)
-rw-r--r--bin/ls/ls.c5
1 files changed, 4 insertions, 1 deletions
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);
}
/*