]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41085: Fix array.array.index() on 64-bit Windows (GH-21071)
authorWildCard65 <WildCard65@users.noreply.github.com>
Tue, 23 Jun 2020 13:21:16 +0000 (09:21 -0400)
committerGitHub <noreply@github.com>
Tue, 23 Jun 2020 13:21:16 +0000 (15:21 +0200)
Fix integer overflow in the :meth:`array.array.index` method on 64-bit Windows
for index larger than ``2**31``.

Misc/NEWS.d/next/Tests/2020-06-23-12-02-45.bpo-41085.JZKsyz.rst [new file with mode: 0644]
Modules/arraymodule.c

diff --git a/Misc/NEWS.d/next/Tests/2020-06-23-12-02-45.bpo-41085.JZKsyz.rst b/Misc/NEWS.d/next/Tests/2020-06-23-12-02-45.bpo-41085.JZKsyz.rst
new file mode 100644 (file)
index 0000000..463dffd
--- /dev/null
@@ -0,0 +1,2 @@
+Fix integer overflow in the :meth:`array.array.index` method on 64-bit Windows
+for index larger than ``2**31``.
index 8f12c61646335608d8bdc8c53209b0c38b119c83..2d498c7e829415d02fb40201d24173204fd9e11b 100644 (file)
@@ -1130,7 +1130,7 @@ array_array_index(arrayobject *self, PyObject *v)
         cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
         Py_DECREF(selfi);
         if (cmp > 0) {
-            return PyLong_FromLong((long)i);
+            return PyLong_FromSsize_t(i);
         }
         else if (cmp < 0)
             return NULL;