summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2021-03-19 23:20:57 -0500
committerGitHub <noreply@github.com>2021-03-19 22:20:57 -0600
commit2ccc7942f072b7fdbe54f148cdcb6a7d79388a89 (patch)
tree5df55a661ea03d90542e358250f48f099b5bb29c /numpy/core/src
parentf282603bf1c210e44ffc34e6a464c17a4851a58a (diff)
downloadnumpy-2ccc7942f072b7fdbe54f148cdcb6a7d79388a89.tar.gz
BUG: Fix small valgrind-found issues (#18651)
* BUG: Fix small valgrind-found issues This should be backportable. There was at least one that I could not reproduce when running the tests again. And the new random-shuffle tests give false-positives (which is just slightly annoying, considering that we are very close to almost only "longdouble" related false-positives) * BUG: Add missing decref in user-dtype fallback paths The missing decref here only leaks references and can never leak actual memory fortunately. * MAINT,TST: Simplify the "refcount logic" in the dispatch tests again Using SETREF can be nice, but was just overcomplicating thing here...
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/multiarray/array_coercion.c1
-rw-r--r--numpy/core/src/multiarray/buffer.c1
-rw-r--r--numpy/core/src/multiarray/legacy_dtype_implementation.c2
-rw-r--r--numpy/core/src/umath/_umath_tests.c.src1
4 files changed, 5 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/array_coercion.c b/numpy/core/src/multiarray/array_coercion.c
index 63fa5f511..5be4ea2b2 100644
--- a/numpy/core/src/multiarray/array_coercion.c
+++ b/numpy/core/src/multiarray/array_coercion.c
@@ -748,6 +748,7 @@ find_descriptor_from_array(
NULL, DType, &flags, item_DType) < 0) {
Py_DECREF(iter);
Py_DECREF(elem);
+ Py_XDECREF(*out_descr);
Py_XDECREF(item_DType);
return -1;
}
diff --git a/numpy/core/src/multiarray/buffer.c b/numpy/core/src/multiarray/buffer.c
index 813850224..5458c81cc 100644
--- a/numpy/core/src/multiarray/buffer.c
+++ b/numpy/core/src/multiarray/buffer.c
@@ -878,6 +878,7 @@ void_getbuffer(PyObject *self, Py_buffer *view, int flags)
*/
_buffer_info_t *info = _buffer_get_info(&scalar->_buffer_info, self, flags);
if (info == NULL) {
+ Py_DECREF(self);
return -1;
}
view->format = info->format;
diff --git a/numpy/core/src/multiarray/legacy_dtype_implementation.c b/numpy/core/src/multiarray/legacy_dtype_implementation.c
index 3ce4710fd..d2e95348d 100644
--- a/numpy/core/src/multiarray/legacy_dtype_implementation.c
+++ b/numpy/core/src/multiarray/legacy_dtype_implementation.c
@@ -161,10 +161,12 @@ PyArray_LegacyCanCastSafely(int fromtype, int totype)
while (*curtype != NPY_NOTYPE) {
if (*curtype++ == totype) {
+ Py_DECREF(from);
return 1;
}
}
}
+ Py_DECREF(from);
return 0;
}
diff --git a/numpy/core/src/umath/_umath_tests.c.src b/numpy/core/src/umath/_umath_tests.c.src
index 750fbeb92..4e250e43b 100644
--- a/numpy/core/src/umath/_umath_tests.c.src
+++ b/numpy/core/src/umath/_umath_tests.c.src
@@ -614,6 +614,7 @@ UMath_Tests_test_dispatch(PyObject *NPY_UNUSED(dummy), PyObject *NPY_UNUSED(dumm
if (item == NULL || PyDict_SetItemString(dict, "@str@", item) < 0) {
goto err;
}
+ Py_DECREF(item);
/**end repeat**/
item = PyList_New(0);
if (item == NULL || PyDict_SetItemString(dict, "all", item) < 0) {