From: Victor Stinner Date: Thu, 31 Oct 2013 15:33:05 +0000 (+0100) Subject: Issue #19437: Fix PyCArrayType constructor, raise MemoryError on PyMem_Malloc() X-Git-Tag: v3.4.0b1~451 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a215002453880eb5f62786cb0010065e3dc3bf74;p=thirdparty%2FPython%2Fcpython.git Issue #19437: Fix PyCArrayType constructor, raise MemoryError on PyMem_Malloc() failure --- diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 9c81247ab87b..32d67b00f59c 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));