Author: Bernd Schoeller <[email protected]>
Branch: py3.7
Changeset: r97940:9f57693bca37
Date: 2019-11-02 16:45 +0000
http://bitbucket.org/pypy/pypy/changeset/9f57693bca37/

Log:    Checking for overflow in ctypes array creation (fixing
        test.test_ctypes)

diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py
--- a/lib_pypy/_ctypes/array.py
+++ b/lib_pypy/_ctypes/array.py
@@ -275,6 +275,8 @@
         raise TypeError("Can't multiply a ctypes type by a non-integer")
     if length < 0:
         raise ValueError("Array length must be >= 0")
+    if length * base._sizeofinstances() > sys.maxsize:
+        raise OverflowError("array too large")
     key = (base, length)
     try:
         return ARRAY_CACHE[key]
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to