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
This commit is contained in:
parent
d6f8c236b8
commit
8cd46ae7bc
@ -143,7 +143,7 @@ output(void)
|
|||||||
char buf[4096];
|
char buf[4096];
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if(!nflag)
|
if(!nflag && dirbuf!=0)
|
||||||
qsort(dirbuf, ndir, sizeof dirbuf[0], (int (*)(const void*, const void*))compar);
|
qsort(dirbuf, ndir, sizeof dirbuf[0], (int (*)(const void*, const void*))compar);
|
||||||
for(i=0; i<ndir; i++)
|
for(i=0; i<ndir; i++)
|
||||||
dowidths(dirbuf[i].d);
|
dowidths(dirbuf[i].d);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user