summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2022-05-23 15:59:24 -0700
committerSebastian Berg <sebastian@sipsolutions.net>2022-05-23 18:26:21 -0700
commit447f21c889930354abc66ab2b2285208eecc3b6c (patch)
tree6bc4a5cddac996d749b889be6dbda2f5050b124c /numpy
parent4cb2928efa21ecac03429b5050edbf1a9b032bfc (diff)
downloadnumpy-447f21c889930354abc66ab2b2285208eecc3b6c.tar.gz
MAINT: Do not steal reference in zerofill on error
This fixes the path that caused a double decref in one of the error paths. (This was de-facto unreachable of course, since zero-filling should never actually fail.) Closes gh-19859
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/common.c1
-rw-r--r--numpy/core/src/multiarray/getset.c1
2 files changed, 1 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/common.c b/numpy/core/src/multiarray/common.c
index aa612146c..da8d23a26 100644
--- a/numpy/core/src/multiarray/common.c
+++ b/numpy/core/src/multiarray/common.c
@@ -136,7 +136,6 @@ _zerofill(PyArrayObject *ret)
PyArray_FillObjectArray(ret, zero);
Py_DECREF(zero);
if (PyErr_Occurred()) {
- Py_DECREF(ret);
return -1;
}
}
diff --git a/numpy/core/src/multiarray/getset.c b/numpy/core/src/multiarray/getset.c
index eb55e5e61..ab35548ed 100644
--- a/numpy/core/src/multiarray/getset.c
+++ b/numpy/core/src/multiarray/getset.c
@@ -808,6 +808,7 @@ array_imag_get(PyArrayObject *self, void *NPY_UNUSED(ignored))
return NULL;
}
if (_zerofill(ret) < 0) {
+ Py_DECREF(ret);
return NULL;
}
PyArray_CLEARFLAGS(ret, NPY_ARRAY_WRITEABLE);