1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

fsp: Don't call qsort with a NULL pointer.

This commit is contained in:
Kalle Olavi Niemitalo 2007-03-05 21:36:36 +02:00 committed by Kalle Olavi Niemitalo
parent f1d400ab3e
commit 97edc3a2cc

View File

@ -188,7 +188,10 @@ sort_and_display_entries(FSP_DIR *dir, const unsigned char dircolor[])
copy_struct(&table[size], &fentry);
size++;
}
qsort(table, size, sizeof(*table), compare);
/* If size==0, then table==NULL. According to ISO/IEC 9899:1999
* 7.20.5p1, the NULL must not be given to qsort. */
if (size > 0)
qsort(table, size, sizeof(*table), compare);
for (i = 0; i < size; i++) {
display_entry(&table[i], dircolor);