diff --git a/include/dirent.h b/include/dirent.h index fe99484..fd1e813 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -1068,8 +1068,10 @@ scandir( exit_success: /* Sort directory entries */ - qsort(files, size, sizeof(void*), - (int (*) (const void*, const void*)) compare); + if (size > 1 && compare) { + qsort(files, size, sizeof(void*), + (int (*) (const void*, const void*)) compare); + } /* Pass pointer table to caller */ if (namelist)