diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-10-31 15:33:05 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-10-31 15:33:05 (GMT) |
commit | a215002453880eb5f62786cb0010065e3dc3bf74 (patch) | |
tree | 186b9bc5694f102e55b6c1d2d1e78f0f3097e26c /Modules/_ctypes | |
parent | ba9be477b0098eefeae2dd36e9261434d83bfb57 (diff) | |
download | cpython-a215002453880eb5f62786cb0010065e3dc3bf74.zip cpython-a215002453880eb5f62786cb0010065e3dc3bf74.tar.gz cpython-a215002453880eb5f62786cb0010065e3dc3bf74.tar.bz2 |
Issue #19437: Fix PyCArrayType constructor, raise MemoryError on PyMem_Malloc()
failure
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 9c81247..32d67b0 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -1309,8 +1309,10 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) goto error; stgdict->ndim = itemdict->ndim + 1; stgdict->shape = PyMem_Malloc(sizeof(Py_ssize_t) * stgdict->ndim); - if (stgdict->shape == NULL) + if (stgdict->shape == NULL) { + PyErr_NoMemory(); goto error; + } stgdict->shape[0] = length; memmove(&stgdict->shape[1], itemdict->shape, sizeof(Py_ssize_t) * (stgdict->ndim - 1)); |