]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add back some safeguards on the index elements that were lost in the
authorGuido van Rossum <guido@python.org>
Wed, 25 Feb 1998 17:50:03 +0000 (17:50 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 25 Feb 1998 17:50:03 +0000 (17:50 +0000)
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)

Objects/listobject.c

index a5bd038a3fb9ba9a3b4158faf188ea3742c75e11..8bec8afc7072af2ac366d5a80509d1909d5b89ff 100644 (file)
@@ -719,7 +719,7 @@ quicksort(array, size, compare)
                r = hi-2;
                for (;;) {
                        /* Move left index to element > pivot */
-                       for (;;) {
+                       while (l < hi) {
                                k = docompare(*l, pivot, compare); 
                                if (k == CMPERROR)
                                        return -1;
@@ -728,7 +728,7 @@ quicksort(array, size, compare)
                                l++;
                        }
                        /* Move right index to element < pivot */
-                       for (;;) {
+                       while (r >= lo) {
                                k = docompare(pivot, *r, compare);
                                if (k == CMPERROR)
                                        return -1;