Issue #19437: Fix PyCArrayType constructor, raise MemoryError on PyMem_Malloc()

failure
This commit is contained in:
Victor Stinner 2013-10-31 16:33:05 +01:00
parent ba9be477b0
commit a215002453

View file

@ -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));