ls: Release resources before returning from traverse()

PR:		278476
MFC after:	2 weeks
Reported by:	valgrind

(cherry picked from commit e6c9c463384d11a44af3e5f2cc947fb69f3a1968)
This commit is contained in:
Mark Johnston 2025-01-14 14:20:26 +00:00
parent be53f73266
commit 66ff03065d

View file

@ -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);
}
/*