From f8adfe947e614ac47b127daea24fedbacf528b9a Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 9 Feb 2023 20:09:31 +0300 Subject: [PATCH 1/2] gh-101747: Fix refleak in new `OrderedDict` repr --- Objects/odictobject.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Objects/odictobject.c b/Objects/odictobject.c index ab2bbed35873de..8bf1e606067ecc 100644 --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -1388,6 +1388,7 @@ odict_repr(PyODictObject *self) Done: Py_ReprLeave((PyObject *)self); + Py_XDECREF(dcopy); return result; } From dce3ec1ca514390cb79d0c847d6a601c91dd52c3 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Fri, 10 Feb 2023 02:02:43 +0300 Subject: [PATCH 2/2] Apply code review suggestion --- Objects/odictobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/odictobject.c b/Objects/odictobject.c index 8bf1e606067ecc..215a8af54fb266 100644 --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -1385,10 +1385,10 @@ odict_repr(PyODictObject *self) result = PyUnicode_FromFormat("%s(%R)", _PyType_Name(Py_TYPE(self)), dcopy); + Py_DECREF(dcopy); Done: Py_ReprLeave((PyObject *)self); - Py_XDECREF(dcopy); return result; }