Commit d2ea0561 authored by Guido van Rossum's avatar Guido van Rossum

Add back some safeguards on the index elements that were lost in the

last patch.  Dave Ascher found a case that dumps core without these:

def myComparison(x,y):
    return cmp(x%3,y%7)

z = range(12)
z.sort(myComparison)
parent b1b743b7
...@@ -719,7 +719,7 @@ quicksort(array, size, compare) ...@@ -719,7 +719,7 @@ quicksort(array, size, compare)
r = hi-2; r = hi-2;
for (;;) { for (;;) {
/* Move left index to element > pivot */ /* Move left index to element > pivot */
for (;;) { while (l < hi) {
k = docompare(*l, pivot, compare); k = docompare(*l, pivot, compare);
if (k == CMPERROR) if (k == CMPERROR)
return -1; return -1;
...@@ -728,7 +728,7 @@ quicksort(array, size, compare) ...@@ -728,7 +728,7 @@ quicksort(array, size, compare)
l++; l++;
} }
/* Move right index to element < pivot */ /* Move right index to element < pivot */
for (;;) { while (r >= lo) {
k = docompare(pivot, *r, compare); k = docompare(pivot, *r, compare);
if (k == CMPERROR) if (k == CMPERROR)
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment