tls: check that pointer is not nil before calling qsort - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 8cd46ae7bc031f311c833ad32445f5cde1916f99
 (DIR) parent d6f8c236b8c601781cef6f8521fd47dffa1758b4
 (HTM) Author: Neven Sajko <nsajko@gmail.com>
       Date:   Sat, 28 May 2016 03:13:35 +0200
       
       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
       
       Diffstat:
         M src/cmd/ls.c                        |       2 +-
       
       1 file changed, 1 insertion(+), 1 deletion(-)
       ---
 (DIR) diff --git a/src/cmd/ls.c b/src/cmd/ls.c
       t@@ -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<ndir; i++)
                        dowidths(dirbuf[i].d);