commit: be69812ae6332bbd3a00f00dbdcb928176c3a1dc
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 10 13:34:56 2019 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 10 13:34:56 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=be69812a
libq/scandirat: support compar being NULL
The specs say that if compar is NULL no sorting happens, so just don't
sort if it is NULL (instead of crashing).
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
libq/scandirat.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libq/scandirat.c b/libq/scandirat.c
index b3d0cfe..f28ba0d 100644
--- a/libq/scandirat.c
+++ b/libq/scandirat.c
@@ -64,7 +64,8 @@ scandirat(int dir_fd, const char *dir, struct dirent
***dirlist,
}
*dirlist = ret;
- qsort(ret, retlen, sizeof(*ret), (void *)compar);
+ if (compar != NULL)
+ qsort(ret, retlen, sizeof(*ret), (void *)compar);
/* closes underlying fd */
closedir(dirp);