diff options
author | Matti Picus <matti.picus@gmail.com> | 2021-02-24 18:06:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-24 18:06:05 +0200 |
commit | 2eb2e93ef43618f01258c43f4e7024cb5e3fc173 (patch) | |
tree | 81606e0804534d66c0bb5952247959c8764c87ce | |
parent | 98cb6bc8522b89ef308da40a26fa910fd1a17097 (diff) | |
parent | e2740334e8f205faee2e307db44bcc2c65ca586e (diff) | |
download | numpy-2eb2e93ef43618f01258c43f4e7024cb5e3fc173.tar.gz |
Merge pull request #18479 from cgohlke/patch-4
BUG: check if PyArray_malloc succeeded
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index cd6e27a35..f30f31a2e 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -5219,7 +5219,12 @@ PyUFunc_RegisterLoopForDescr(PyUFuncObject *ufunc, if (cmp == 0 && current != NULL && current->arg_dtypes == NULL) { current->arg_dtypes = PyArray_malloc(ufunc->nargs * sizeof(PyArray_Descr*)); - if (arg_dtypes != NULL) { + if (current->arg_dtypes == NULL) { + PyErr_NoMemory(); + result = -1; + goto done; + } + else if (arg_dtypes != NULL) { for (i = 0; i < ufunc->nargs; i++) { current->arg_dtypes[i] = arg_dtypes[i]; Py_INCREF(current->arg_dtypes[i]); |