[syslinux:pathbased] qsort: handle the case of zero entries
syslinux-bot for H. Peter Anvin
hpa at zytor.com
Sat Mar 6 14:54:13 PST 2010
Commit-ID: 600217eb7036a64630a3edd6b093d97b883a9b5c
Gitweb: http://syslinux.zytor.com/commit/600217eb7036a64630a3edd6b093d97b883a9b5c
Author: H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sat, 6 Mar 2010 14:49:10 -0800
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Sat, 6 Mar 2010 14:49:10 -0800
qsort: handle the case of zero entries
Avoid bugs when the qsorted array is empty.
Signed-off-by: H. Peter Anvin <hpa at zytor.com>
---
com32/lib/qsort.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/com32/lib/qsort.c b/com32/lib/qsort.c
index a67866d..a9d646c 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;
More information about the Syslinux-commits
mailing list