Skip to content

Commit f8b5344

Browse files
sthbenjaminp
authored andcommitted
closes bpo-35623: Fix integer overflow when sorting large lists (GH-11380)
There is already a `Py_ssize_t i` defined at function scope that is used for similar loops. By removing the local `int i` declaration that `i` is used, which has the appropriate type.
1 parent 7e3fb40 commit f8b5344

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a crash when sorting very long lists. Patch by Stephan Hohe.

Objects/listobject.c

-1
Original file line numberDiff line numberDiff line change
@@ -2283,7 +2283,6 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
22832283
int ints_are_bounded = 1;
22842284

22852285
/* Prove that assumption by checking every key. */
2286-
int i;
22872286
for (i=0; i < saved_ob_size; i++) {
22882287

22892288
if (keys_are_in_tuples &&

0 commit comments

Comments
 (0)