diff options
| author | Eric Wieser <wieser.eric@gmail.com> | 2018-02-09 00:56:15 -0800 |
|---|---|---|
| committer | Eric Wieser <wieser.eric@gmail.com> | 2018-02-09 01:04:29 -0800 |
| commit | 3bce2be74f228684ca2895ad02b63953f37e2a9d (patch) | |
| tree | d0a580f8d1f5f6d98ee5520cffc6fcd3b7ab9be0 /numpy/core/src | |
| parent | 4cfac4067a27835de6b0ae204df0e8c91998c1f2 (diff) | |
| download | numpy-3bce2be74f228684ca2895ad02b63953f37e2a9d.tar.gz | |
BUG: Add missing PyErr_NoMemory() after malloc
Diffstat (limited to 'numpy/core/src')
| -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; |
