summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2021-09-23 06:58:00 -0700
committerGitHub <noreply@github.com>2021-09-23 06:58:00 -0700
commit4a60e7099ec6c69b5ceeaecb5c71836d39662c31 (patch)
treef44fa1e007d2253efcf038c6a12929c8f4e307ad /numpy
parentc64c7cc0b36256581c29311675af3f50b0f2df3e (diff)
parentec6b1aef8d81a06385f9602688c500009f71b41c (diff)
downloadnumpy-4a60e7099ec6c69b5ceeaecb5c71836d39662c31.tar.gz
Merge pull request #19934 from WarrenWeckesser/gh19931-memleak
BUG: core: Fix memory leak in the C function boundarraymethod_repr.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/array_method.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/array_method.c b/numpy/core/src/multiarray/array_method.c
index 03d67c81b..c4db73c3b 100644
--- a/numpy/core/src/multiarray/array_method.c
+++ b/numpy/core/src/multiarray/array_method.c
@@ -466,7 +466,6 @@ NPY_NO_EXPORT PyTypeObject PyArrayMethod_Type = {
};
-
static PyObject *
boundarraymethod_repr(PyBoundArrayMethodObject *self)
{
@@ -476,9 +475,11 @@ boundarraymethod_repr(PyBoundArrayMethodObject *self)
if (dtypes == NULL) {
return NULL;
}
- return PyUnicode_FromFormat(
- "<np._BoundArrayMethod `%s` for dtypes %S>",
- self->method->name, dtypes);
+ PyObject *repr = PyUnicode_FromFormat(
+ "<np._BoundArrayMethod `%s` for dtypes %S>",
+ self->method->name, dtypes);
+ Py_DECREF(dtypes);
+ return repr;
}