about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-02-17 00:03:24 -0500
committerRich Felker <dalias@aerifal.cx>2011-02-17 00:03:24 -0500
commitb24bc15f5c3828184f123698b4b545fef4edac99 (patch)
treee89003e46ae8bfd2c5583edfde5761c6394a6042 /src
parent798a12ecc4ec4a7780beaf2f5fb86ffbc9738755 (diff)
downloadmusl-b24bc15f5c3828184f123698b4b545fef4edac99.tar.gz
musl-b24bc15f5c3828184f123698b4b545fef4edac99.tar.xz
musl-b24bc15f5c3828184f123698b4b545fef4edac99.zip
don't compare elements with themselves during qsort.
this is actually a workaround for a bug in gcc, whereby it asserts
inequality of the keys being compared...
Diffstat (limited to 'src')
-rw-r--r--src/stdlib/qsort.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/stdlib/qsort.c b/src/stdlib/qsort.c
index f5bf3d02..91a3361d 100644
--- a/src/stdlib/qsort.c
+++ b/src/stdlib/qsort.c
@@ -28,7 +28,7 @@ static void sift(char *base, size_t root, size_t nel, size_t width, int (*cmp)(c
 		max = 2*root;
 		if (max < nel && cmp(base+max*width, base+(max+1)*width) < 0)
 			max++;
-		if (cmp(base+root*width, base+max*width) < 0) {
+		if (max && cmp(base+root*width, base+max*width) < 0) {
 			swap(base+root*width, base+max*width, width);
 			root = max;
 		} else break;