diff options
author | Christian Heimes <christian@cheimes.de> | 2007-12-05 09:33:00 +0000 |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-12-05 09:33:00 +0000 |
commit | 0d7f7e3e005d18e55dd5d902336f1dc893e5438b (patch) | |
tree | 3375e0dee8d184d9efddfd0389e594a015191b1e /Modules/_ctypes | |
parent | d823e1feffc7072ed0ee99ceb10b8a9d2aa37f11 (diff) | |
download | cpython-0d7f7e3e005d18e55dd5d902336f1dc893e5438b.tar.gz |
Fixed problem with missing PyInt_CheckExact() macro in _ctypes.c
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 00643ac9a7..54e7963813 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -954,8 +954,8 @@ ArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) StgDictObject *itemdict; PyObject *proto; PyObject *typedict; - int length; - + long length; + int overflow; Py_ssize_t itemsize, itemalign; typedict = PyTuple_GetItem(args, 2); @@ -963,13 +963,18 @@ ArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; proto = PyDict_GetItemString(typedict, "_length_"); /* Borrowed ref */ - if (!proto || !PyInt_CheckExact(proto)) { + if (!proto || !PyLong_Check(proto)) { PyErr_SetString(PyExc_AttributeError, "class must define a '_length_' attribute, " "which must be a positive integer"); return NULL; } - length = PyLong_AS_LONG(proto); + length = PyLong_AsLongAndOverflow(proto, &overflow); + if (overflow) { + PyErr_SetString(PyExc_OverflowError, + "The '_length_' attribute is too large"); + return NULL; + } proto = PyDict_GetItemString(typedict, "_type_"); /* Borrowed ref */ if (!proto) { |