Don't qsort() NULL.

Found by: clang static analyzer
This commit is contained in:
Emil Mikulic 2011-01-15 20:38:31 +11:00
parent 1b7bbcc033
commit ccbe7cffa7

View File

@ -1512,7 +1512,9 @@ static ssize_t make_sorted_dirlist(const char *path, struct dlent ***output) {
}
closedir(dir);
free(currname);
qsort(list, entries, sizeof(struct dlent*), dlent_cmp);
assert(list != NULL);
if (list) /* there's gotta be at least ".." */
qsort(list, entries, sizeof(struct dlent*), dlent_cmp);
*output = xrealloc(list, sizeof(struct dlent*) * entries);
return (ssize_t)entries;
#undef POOL_INCR