]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
closes bpo-35623: Fix integer overflow when sorting large lists (GH-11380)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 2 Jan 2019 02:25:23 +0000 (18:25 -0800)
committerGitHub <noreply@github.com>
Wed, 2 Jan 2019 02:25:23 +0000 (18:25 -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.
(cherry picked from commit f8b534477a2a51d85ea1663530f685f805f2b247)

Co-authored-by: sth <sth.dev@tejp.de>
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 c8ffeff09368de048b8837f7f5d4853da6f0231d..de73b8bf80fdfd01848425e9e466229ef6a53f96 100644 (file)
@@ -2232,7 +2232,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 &&