From f3fc956d5260e0050c5044cb80e262b2104d0394 Mon Sep 17 00:00:00 2001 From: Peter Hawkins Date: Tue, 18 Jul 2023 21:02:27 +0000 Subject: [PATCH] Fix reference count leak in str(scalar). PyArray_DescrFromTypeObject() returns a fresh reference to the descriptor object, which must be freed. This leak was introduced in https://github.com/numpy/numpy/commit/670842b38005febf64259f268332e46d86233ef0 --- numpy/core/src/multiarray/scalartypes.c.src | 1 + 1 file changed, 1 insertion(+) diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src index fe753f64b1e8..02f3223e7f68 100644 --- a/numpy/core/src/multiarray/scalartypes.c.src +++ b/numpy/core/src/multiarray/scalartypes.c.src @@ -316,6 +316,7 @@ genint_type_str(PyObject *self) item = gentype_generic_method(self, NULL, NULL, "item"); break; } + Py_DECREF(descr); if (item == NULL) { return NULL; }