commit | 17a94c572a48a2268b9749055b6984cc63015965 | [log] [tgz] |
---|---|---|
author | Rob Landley <rob@landley.net> | Tue Jun 23 13:15:13 2015 -0500 |
committer | Rob Landley <rob@landley.net> | Tue Jun 23 13:15:13 2015 -0500 |
tree | 01358f4381c298451938f2bc0ddf7aac6df0ed10 | |
parent | 28727ba7cddb932bfa88eef514e60fe8d337087a [diff] |
Don't depend on malloc(0) to return non-null.
diff --git a/toys/posix/ls.c b/toys/posix/ls.c index 5dc392c..bba3431 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c
@@ -320,7 +320,7 @@ 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