Skip to content

Commit 4a60e70

Browse files
authored
Merge pull request numpy#19934 from WarrenWeckesser/gh19931-memleak
BUG: core: Fix memory leak in the C function boundarraymethod_repr.
2 parents c64c7cc + ec6b1ae commit 4a60e70

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

numpy/core/src/multiarray/array_method.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ NPY_NO_EXPORT PyTypeObject PyArrayMethod_Type = {
466466
};
467467

468468

469-
470469
static PyObject *
471470
boundarraymethod_repr(PyBoundArrayMethodObject *self)
472471
{
@@ -476,9 +475,11 @@ boundarraymethod_repr(PyBoundArrayMethodObject *self)
476475
if (dtypes == NULL) {
477476
return NULL;
478477
}
479-
return PyUnicode_FromFormat(
480-
"<np._BoundArrayMethod `%s` for dtypes %S>",
481-
self->method->name, dtypes);
478+
PyObject *repr = PyUnicode_FromFormat(
479+
"<np._BoundArrayMethod `%s` for dtypes %S>",
480+
self->method->name, dtypes);
481+
Py_DECREF(dtypes);
482+
return repr;
482483
}
483484

484485

0 commit comments

Comments
 (0)