diff options
| author | Victor Stinner <victor.stinner@gmail.com> | 2013-10-31 16:33:05 +0100 |
|---|---|---|
| committer | Victor Stinner <victor.stinner@gmail.com> | 2013-10-31 16:33:05 +0100 |
| commit | a215002453880eb5f62786cb0010065e3dc3bf74 (patch) | |
| tree | 186b9bc5694f102e55b6c1d2d1e78f0f3097e26c | |
| parent | ba9be477b0098eefeae2dd36e9261434d83bfb57 (diff) | |
| download | cpython-git-a215002453880eb5f62786cb0010065e3dc3bf74.tar.gz | |
Issue #19437: Fix PyCArrayType constructor, raise MemoryError on PyMem_Malloc()
failure
| -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 9c81247ab8..32d67b00f5 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)); |
