]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #19437: Fix PyCArrayType constructor, raise MemoryError on PyMem_Malloc()
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 31 Oct 2013 15:33:05 +0000 (16:33 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 31 Oct 2013 15:33:05 +0000 (16:33 +0100)
failure

Modules/_ctypes/_ctypes.c

index 9c81247ab87b3ca9bd2ca9d6c41279d3a61f3135..32d67b00f59c98453b45d5bb95a2e9927a999296 100644 (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));