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

Log:    Checking for overflow in ctypes array creation (fixing
        test.test_ctypes) (grafted from
        9f57693bca378be44fe87174966518b7d9799be6)

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
@@ -267,6 +267,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