]> granicus.if.org Git - python/commitdiff
closes bpo-35623: Fix integer overflow when sorting large lists (GH-11380)
authorsth <sth.dev@tejp.de>
Wed, 2 Jan 2019 02:01:54 +0000 (03:01 +0100)
committerBenjamin Peterson <benjamin@python.org>
Wed, 2 Jan 2019 02:01:54 +0000 (18:01 -0800)
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.

Misc/NEWS.d/next/Core and Builtins/2018-12-31-02-37-20.bpo-35623.24AQhY.rst [new file with mode: 0644]
Objects/listobject.c

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 (file)
index 0000000..6e3df4d
--- /dev/null
@@ -0,0 +1 @@
+Fix a crash when sorting very long lists. Patch by Stephan Hohe.
index 17c37ba9756073dd8ee95808024dc972cdfc120c..e11a3fdd1358de94123d98672a4527115391b3fb 100644 (file)
@@ -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 &&