aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-03-06 14:49:10 -0800
committerH. Peter Anvin <hpa@zytor.com>2010-03-06 14:49:10 -0800
commit600217eb7036a64630a3edd6b093d97b883a9b5c (patch)
treed09196a208ed376b18651f97e97e395fb60b48f6 /com32/lib
parente375515ddc712f1f69ee21337db2a3267caa5d49 (diff)
downloadsyslinux-600217eb7036a64630a3edd6b093d97b883a9b5c.tar.gz
syslinux-600217eb7036a64630a3edd6b093d97b883a9b5c.tar.xz
syslinux-600217eb7036a64630a3edd6b093d97b883a9b5c.zip
qsort: handle the case of zero entries
Avoid bugs when the qsorted array is empty. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/lib')
-rw-r--r--com32/lib/qsort.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/com32/lib/qsort.c b/com32/lib/qsort.c
index a67866d3..a9d646ce 100644
--- a/com32/lib/qsort.c
+++ b/com32/lib/qsort.c
@@ -6,6 +6,7 @@
*/
#include <stddef.h>
+#include <stdlib.h>
#include <string.h>
static inline size_t newgap(size_t gap)
@@ -27,6 +28,9 @@ void qsort(void *base, size_t nmemb, size_t size,
char *p1, *p2;
int swapped;
+ if (!nmemb)
+ return;
+
do {
gap = newgap(gap);
swapped = 0;