From 8cd46ae7bc031f311c833ad32445f5cde1916f99 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Sat, 28 May 2016 03:13:35 +0200 Subject: ls: check that pointer is not nil before calling qsort Passing a null pointer to qsort is an error in C (GCC and Clang agree with the standards there, so this is no joke). Change-Id: Ia2b015793a75ea4e85ae8f47da6beead9c4290e6 --- src/cmd/ls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cmd/ls.c') diff --git a/src/cmd/ls.c b/src/cmd/ls.c index 60615059..fca3ee95 100644 --- a/src/cmd/ls.c +++ b/src/cmd/ls.c @@ -143,7 +143,7 @@ output(void) char buf[4096]; char *s; - if(!nflag) + if(!nflag && dirbuf!=0) qsort(dirbuf, ndir, sizeof dirbuf[0], (int (*)(const void*, const void*))compar); for(i=0; i Date: Fri, 10 Jan 2020 14:44:21 +0000 Subject: Trivial changes: whitespace and modes. Remote whitespace at the ends of lines. Remove blank lines from the ends of files. Change modes on source files so that they are not executable. Signed-off-by: Dan Cross --- src/cmd/ls.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/cmd/ls.c') diff --git a/src/cmd/ls.c b/src/cmd/ls.c index fca3ee95..845532be 100644 --- a/src/cmd/ls.c +++ b/src/cmd/ls.c @@ -249,7 +249,7 @@ growto(long n) if(dirbuf == 0){ fprint(2, "ls: malloc fail\n"); exits("malloc fail"); - } + } } int @@ -305,4 +305,3 @@ asciitime(long l) buf[12] = 0; return buf; } - -- cgit v1.2.3