summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/_simd/_simd_convert.inc1
-rw-r--r--numpy/core/src/multiarray/getset.c1
-rw-r--r--numpy/core/src/multiarray/scalartypes.c.src1
-rw-r--r--numpy/core/src/umath/dispatching.c4
4 files changed, 7 insertions, 0 deletions
diff --git a/numpy/core/src/_simd/_simd_convert.inc b/numpy/core/src/_simd/_simd_convert.inc
index 73869ef1f..46e044479 100644
--- a/numpy/core/src/_simd/_simd_convert.inc
+++ b/numpy/core/src/_simd/_simd_convert.inc
@@ -94,6 +94,7 @@ simd_sequence_from_iterable(PyObject *obj, simd_data_type dtype, Py_ssize_t min_
"minimum acceptable size of the required sequence is %d, given(%d)",
min_size, seq_size
);
+ Py_DECREF(seq_obj);
return NULL;
}
npyv_lanetype_u8 *dst = simd_sequence_new(seq_size, dtype);
diff --git a/numpy/core/src/multiarray/getset.c b/numpy/core/src/multiarray/getset.c
index e81ca2947..2544ca9e7 100644
--- a/numpy/core/src/multiarray/getset.c
+++ b/numpy/core/src/multiarray/getset.c
@@ -401,6 +401,7 @@ array_data_set(PyArrayObject *self, PyObject *op, void *NPY_UNUSED(ignored))
return -1;
}
PyDataMem_UserFREE(PyArray_DATA(self), nbytes, handler);
+ Py_CLEAR(((PyArrayObject_fields *)self)->mem_handler);
}
if (PyArray_BASE(self)) {
if ((PyArray_FLAGS(self) & NPY_ARRAY_WRITEBACKIFCOPY) ||
diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src
index db1e49db8..013526ff0 100644
--- a/numpy/core/src/multiarray/scalartypes.c.src
+++ b/numpy/core/src/multiarray/scalartypes.c.src
@@ -2585,6 +2585,7 @@ gentype_arrtype_getbuffer(PyObject *self, Py_buffer *view, int flags)
"user-defined scalar %R registered for built-in dtype %S? "
"This should be impossible.",
self, descr);
+ Py_DECREF(descr);
return -1;
}
view->ndim = 0;
diff --git a/numpy/core/src/umath/dispatching.c b/numpy/core/src/umath/dispatching.c
index cfeb0b17a..81d47a0e1 100644
--- a/numpy/core/src/umath/dispatching.c
+++ b/numpy/core/src/umath/dispatching.c
@@ -583,6 +583,10 @@ legacy_promote_using_legacy_type_resolver(PyUFuncObject *ufunc,
NPY_UNSAFE_CASTING, (PyArrayObject **)ops, type_tuple,
out_descrs) < 0) {
Py_XDECREF(type_tuple);
+ /* Not all legacy resolvers clean up on failures: */
+ for (int i = 0; i < nargs; i++) {
+ Py_CLEAR(out_descrs[i]);
+ }
return -1;
}
Py_XDECREF(type_tuple);