Skip to content

Commit

Permalink
Merge pull request #55 from ych988/master
Browse files Browse the repository at this point in the history
scandir crashes when compare is null.
  • Loading branch information
tronkko authored Sep 9, 2023
2 parents ee062fe + 7478b8d commit 1cb00d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/dirent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1cb00d7

Please sign in to comment.