From a215002453880eb5f62786cb0010065e3dc3bf74 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 31 Oct 2013 16:33:05 +0100 Subject: Issue #19437: Fix PyCArrayType constructor, raise MemoryError on PyMem_Malloc() failure --- Modules/_ctypes/_ctypes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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)); -- cgit v0.12