[Python-checkins] cpython: Issue #19437: Fix PyCArrayType constructor, raise MemoryError on PyMem_Malloc()
victor.stinner
python-checkins at python.org
Thu Oct 31 17:23:56 CET 2013
http://hg.python.org/cpython/rev/ae4bdd4b7240
changeset: 86804:ae4bdd4b7240
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Oct 31 16:33:05 2013 +0100
summary:
Issue #19437: Fix PyCArrayType constructor, raise MemoryError on PyMem_Malloc()
failure
files:
Modules/_ctypes/_ctypes.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1309,8 +1309,10 @@
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));
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list