git: e6c9c463384d - main - ls: Release resources before returning from traverse()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Jan 2025 15:26:19 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=e6c9c463384d11a44af3e5f2cc947fb69f3a1968
commit e6c9c463384d11a44af3e5f2cc947fb69f3a1968
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-01-14 14:20:26 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-01-14 14:20:26 +0000
ls: Release resources before returning from traverse()
PR: 278476
MFC after: 2 weeks
Reported by: valgrind
---
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 a285838e2ee1..048cfc9293e6 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -643,8 +643,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
@@ -693,6 +695,7 @@ traverse(int argc, char *argv[], int options)
}
if (errno)
err(1, "fts_read");
+ fts_close(ftsp);
}
/*