From 548de2b210d60e4619c69269685ca66a59b29b6b Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 21 May 2015 14:19:20 +0300 Subject: [PATCH] Issue #22955: Fixed reference leak in attrgetter.repr(). --- Modules/_operator.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/_operator.c b/Modules/_operator.c index 9e4db58d767..735affcdbb6 100644 --- a/Modules/_operator.c +++ b/Modules/_operator.c @@ -825,8 +825,10 @@ attrgetter_repr(attrgetterobject *ag) if (ag->nattrs == 1) { PyObject *attrsep = NULL; PyObject *attr = dotjoinattr(PyTuple_GET_ITEM(ag->attr, 0), &attrsep); - if (attr != NULL) + if (attr != NULL) { repr = PyUnicode_FromFormat("%s(%R)", Py_TYPE(ag)->tp_name, attr); + Py_DECREF(attr); + } Py_XDECREF(attrsep); } else {