Skip to content

Commit

Permalink
ls: Release resources before returning from traverse()
Browse files Browse the repository at this point in the history
PR:		278476
MFC after:	2 weeks
Reported by:	valgrind
  • Loading branch information
markjdb committed Jan 14, 2025
1 parent ae4f708 commit e6c9c46
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/ls/ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -693,6 +695,7 @@ traverse(int argc, char *argv[], int options)
}
if (errno)
err(1, "fts_read");
fts_close(ftsp);
}

/*
Expand Down

0 comments on commit e6c9c46

Please sign in to comment.