summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsth <sth.dev@tejp.de>2019-01-02 03:01:54 +0100
committerBenjamin Peterson <benjamin@python.org>2019-01-01 18:01:54 -0800
commitf8b534477a2a51d85ea1663530f685f805f2b247 (patch)
tree4451d5f9b3737e1bedb15f445ba10e3f2e8de007
parent7e3fb40b923cb09ecc67816d3191197868593737 (diff)
downloadcpython-git-f8b534477a2a51d85ea1663530f685f805f2b247.tar.gz
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.
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2018-12-31-02-37-20.bpo-35623.24AQhY.rst1
-rw-r--r--Objects/listobject.c1
2 files changed, 1 insertions, 1 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-12-31-02-37-20.bpo-35623.24AQhY.rst b/Misc/NEWS.d/next/Core and Builtins/2018-12-31-02-37-20.bpo-35623.24AQhY.rst
new file mode 100644
index 0000000000..6e3df4dc5d
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2018-12-31-02-37-20.bpo-35623.24AQhY.rst
@@ -0,0 +1 @@
+Fix a crash when sorting very long lists. Patch by Stephan Hohe.
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 17c37ba975..e11a3fdd13 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -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 &&