[Toybox] [PATCH] Stop "ls nonexistent" from segfaulting

Felix Janda felix.janda at posteo.de
Mon Jun 15 09:44:22 PDT 2015


---
Maybe it is better to have the test somewhere else.
---
 toys/posix/ls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 15796ff..3346968 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -539,7 +539,7 @@ void ls_main(void)
   for (dt = TT.files->child; dt; dt = dt->next) dt->parent = TT.files;
 
   // Display the files we collected
-  listfiles(AT_FDCWD, TT.files);
+  if (TT.files->child) listfiles(AT_FDCWD, TT.files);
 
   if (CFG_TOYBOX_FREE) free(TT.files);
 }
-- 
2.3.6

 1434386662.0


More information about the Toybox mailing list