From: Guido van Rossum Date: Wed, 25 Feb 1998 17:50:03 +0000 (+0000) Subject: Add back some safeguards on the index elements that were lost in the X-Git-Tag: v1.5.1~572 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=044b9dc1d717d5ec127a19095f0d803a3249c5b3;p=thirdparty%2FPython%2Fcpython.git 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) --- diff --git a/Objects/listobject.c b/Objects/listobject.c index a5bd038a3fb9..8bec8afc7072 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -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;