diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-06-23 13:40:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-23 13:40:47 (GMT) |
commit | c6e24e7420a03a1751004e255a6f6c14265b9ea1 (patch) | |
tree | 25ae44795f2007850d3a9913d551083413799168 | |
parent | 56d25add07093701c4827ea3a46b7025d9030f3c (diff) | |
download | cpython-c6e24e7420a03a1751004e255a6f6c14265b9ea1.zip cpython-c6e24e7420a03a1751004e255a6f6c14265b9ea1.tar.gz cpython-c6e24e7420a03a1751004e255a6f6c14265b9ea1.tar.bz2 |
bpo-41085: Fix array.array.index() on 64-bit Windows (GH-21071)
Fix integer overflow in the :meth:`array.array.index` method on 64-bit Windows
for index larger than ``2**31``.
(cherry picked from commit 1d3dad5f96ed445b958ec53dfa0d46812f2162d9)
Co-authored-by: WildCard65 <WildCard65@users.noreply.github.com>
-rw-r--r-- | Misc/NEWS.d/next/Tests/2020-06-23-12-02-45.bpo-41085.JZKsyz.rst | 2 | ||||
-rw-r--r-- | Modules/arraymodule.c | 2 |
2 files changed, 3 insertions, 1 deletions
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 index 0000000..463dffd --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2020-06-23-12-02-45.bpo-41085.JZKsyz.rst @@ -0,0 +1,2 @@ +Fix integer overflow in the :meth:`array.array.index` method on 64-bit Windows +for index larger than ``2**31``. diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 5289ea0..abcdd1e 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1136,7 +1136,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; |