aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/ls.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-06-23 13:15:13 -0500
committerRob Landley <rob@landley.net>2015-06-23 13:15:13 -0500
commit17a94c572a48a2268b9749055b6984cc63015965 (patch)
tree01358f4381c298451938f2bc0ddf7aac6df0ed10 /toys/posix/ls.c
parent28727ba7cddb932bfa88eef514e60fe8d337087a (diff)
downloadtoybox-17a94c572a48a2268b9749055b6984cc63015965.tar.gz
Don't depend on malloc(0) to return non-null.
Diffstat (limited to 'toys/posix/ls.c')
-rw-r--r--toys/posix/ls.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 5dc392c9..bba34313 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -320,7 +320,7 @@ static void listfiles(int dirfd, struct dirtree *indir)
for (sort = 0;;sort = xmalloc(dtlen*sizeof(void *))) {
for (dtlen = 0, dt = indir->child; dt; dt = dt->next, dtlen++)
if (sort) sort[dtlen] = dt;
- if (sort) break;
+ if (sort || !dtlen) break;
}
// Label directory if not top of tree, or if -R