Skip to content

Commit

Permalink
closes bpo-35623: Fix integer overflow when sorting large lists (pyth…
Browse files Browse the repository at this point in the history
…onGH-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.
  • Loading branch information
sth authored and benjaminp committed Jan 2, 2019
1 parent 7e3fb40 commit f8b5344
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a crash when sorting very long lists. Patch by Stephan Hohe.
1 change: 0 additions & 1 deletion Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,6 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
int ints_are_bounded = 1;

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

if (keys_are_in_tuples &&
Expand Down

0 comments on commit f8b5344

Please sign in to comment.