Commit 5717ac53 authored by Victor Stinner's avatar Victor Stinner

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

failure
parent b6918cdb
...@@ -1309,8 +1309,10 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) ...@@ -1309,8 +1309,10 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
goto error; goto error;
stgdict->ndim = itemdict->ndim + 1; stgdict->ndim = itemdict->ndim + 1;
stgdict->shape = PyMem_Malloc(sizeof(Py_ssize_t) * stgdict->ndim); stgdict->shape = PyMem_Malloc(sizeof(Py_ssize_t) * stgdict->ndim);
if (stgdict->shape == NULL) if (stgdict->shape == NULL) {
PyErr_NoMemory();
goto error; goto error;
}
stgdict->shape[0] = length; stgdict->shape[0] = length;
memmove(&stgdict->shape[1], itemdict->shape, memmove(&stgdict->shape[1], itemdict->shape,
sizeof(Py_ssize_t) * (stgdict->ndim - 1)); sizeof(Py_ssize_t) * (stgdict->ndim - 1));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment