diff options
author | Allan Haldane <ealloc@gmail.com> | 2018-02-10 00:18:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-10 00:18:46 +0100 |
commit | 30d8feec54abc180979a7db8df07150cfae5201f (patch) | |
tree | ce431faf9636e040c7cff121ed0b0939f5466e32 /numpy | |
parent | dfad6d530866300f4e964486be2d963204636daa (diff) | |
parent | 3bce2be74f228684ca2895ad02b63953f37e2a9d (diff) | |
download | numpy-30d8feec54abc180979a7db8df07150cfae5201f.tar.gz |
Merge pull request #10555 from eric-wieser/malloc-no-memory
BUG: Add missing PyErr_NoMemory() after malloc
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarray/convert_datatype.c | 2 | ||||
-rw-r--r-- | numpy/core/src/multiarray/multiarraymodule.c | 11 |
2 files changed, 6 insertions, 7 deletions
diff --git a/numpy/core/src/multiarray/convert_datatype.c b/numpy/core/src/multiarray/convert_datatype.c index 6ff381862..2effedb11 100644 --- a/numpy/core/src/multiarray/convert_datatype.c +++ b/numpy/core/src/multiarray/convert_datatype.c @@ -1765,7 +1765,7 @@ PyArray_ResultType(npy_intp narrs, PyArrayObject **arr, PyArray_Descr **all_dtypes = PyArray_malloc( sizeof(*all_dtypes) * (narrs + ndtypes)); if (all_dtypes == NULL) { - return NULL; + return PyErr_NoMemory(); } for (i = 0; i < narrs; ++i) { all_dtypes[i] = PyArray_DESCR(arr[i]); diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index 3e322c7e2..0008cb04b 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -237,7 +237,8 @@ PyArray_AsCArray(PyObject **op, void *ptr, npy_intp *dims, int nd, n = PyArray_DIMS(ap)[0]; ptr2 = (char **)PyArray_malloc(n * sizeof(char *)); if (!ptr2) { - goto fail; + PyErr_NoMemory(); + return -1; } for (i = 0; i < n; i++) { ptr2[i] = PyArray_BYTES(ap) + i*PyArray_STRIDES(ap)[0]; @@ -249,7 +250,8 @@ PyArray_AsCArray(PyObject **op, void *ptr, npy_intp *dims, int nd, m = PyArray_DIMS(ap)[1]; ptr3 = (char ***)PyArray_malloc(n*(m+1) * sizeof(char *)); if (!ptr3) { - goto fail; + PyErr_NoMemory(); + return -1; } for (i = 0; i < n; i++) { ptr3[i] = (char **) &ptr3[n + m * i]; @@ -262,10 +264,6 @@ PyArray_AsCArray(PyObject **op, void *ptr, npy_intp *dims, int nd, memcpy(dims, PyArray_DIMS(ap), nd*sizeof(npy_intp)); *op = (PyObject *)ap; return 0; - -fail: - PyErr_SetString(PyExc_MemoryError, "no memory"); - return -1; } /* Deprecated --- Use PyArray_AsCArray instead */ @@ -1329,6 +1327,7 @@ _pyarray_revert(PyArrayObject *ret) else { char *tmp = PyArray_malloc(PyArray_DESCR(ret)->elsize); if (tmp == NULL) { + PyErr_NoMemory(); return -1; } sw2 = op + (length - 1) * os; |