diff options
author | Hugo Defois <hugo.defois@symphonyretailai.com> | 2021-07-07 23:54:23 +0200 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2021-09-29 14:03:11 -0500 |
commit | c2de2d1fed4a7fd69e439d25bfb1b91f9df6bd1e (patch) | |
tree | 7423747755ae34e9a4761b7e1341fe22e5572a7c | |
parent | 93fd427d5061dbec7684208317e08e887a996043 (diff) | |
download | numpy-c2de2d1fed4a7fd69e439d25bfb1b91f9df6bd1e.tar.gz |
BUG: fix a PyArray_CastScalarToCtype leak
-rw-r--r-- | numpy/core/src/multiarray/scalarapi.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/scalarapi.c b/numpy/core/src/multiarray/scalarapi.c index e409e9874..28c010f8f 100644 --- a/numpy/core/src/multiarray/scalarapi.c +++ b/numpy/core/src/multiarray/scalarapi.c @@ -235,6 +235,7 @@ PyArray_CastScalarToCtype(PyObject *scalar, void *ctypeptr, descr = PyArray_DescrFromScalar(scalar); castfunc = PyArray_GetCastFunc(descr, outcode->type_num); if (castfunc == NULL) { + Py_XDECREF(descr); return -1; } if (PyTypeNum_ISEXTENDED(descr->type_num) || @@ -254,6 +255,7 @@ PyArray_CastScalarToCtype(PyObject *scalar, void *ctypeptr, NPY_ARRAY_CARRAY, NULL); if (aout == NULL) { Py_DECREF(ain); + Py_DECREF(descr); return -1; } castfunc(PyArray_DATA(ain), PyArray_DATA(aout), 1, ain, aout); |