aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-06-23 13:56:53 -0500
committerRob Landley <rob@landley.net>2015-06-23 13:56:53 -0500
commit9acbbafefafbbb7b13bb15c1619e351f9b67a23d (patch)
treed7dc80912a22934078143482d981ab05f5950fb0 /toys
parent17a94c572a48a2268b9749055b6984cc63015965 (diff)
downloadtoybox-9acbbafefafbbb7b13bb15c1619e351f9b67a23d.tar.gz
Don't segfault if none of the file arguments to ls exists.
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/ls.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index bba34313..44915fa7 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -298,7 +298,8 @@ static void listfiles(int dirfd, struct dirtree *indir)
// Silently descend into single directory listed by itself on command line.
// In this case only show dirname/total header when given -R.
dt = indir->child;
- if (S_ISDIR(dt->st.st_mode) && !dt->next && !(flags&(FLAG_d|FLAG_R))) {
+ if (dt && S_ISDIR(dt->st.st_mode) && !dt->next && !(flags&(FLAG_d|FLAG_R)))
+ {
listfiles(open(dt->name, 0), TT.singledir = dt);
return;