From 97edc3a2ccdfe1a56edbdf3b387e09d8f02263e8 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Mon, 5 Mar 2007 21:36:36 +0200 Subject: [PATCH] fsp: Don't call qsort with a NULL pointer. --- src/protocol/fsp/fsp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/protocol/fsp/fsp.c b/src/protocol/fsp/fsp.c index 344d1c02..f444788a 100644 --- a/src/protocol/fsp/fsp.c +++ b/src/protocol/fsp/fsp.c @@ -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);