From c39cd783fb9277ca98816d375471717aff6c6a74 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Wed, 15 Feb 2012 02:42:46 +0100 Subject: Issue #13015: Fix a possible reference leak in defaultdict.__repr__. Patch by Suman Saha. --- Misc/NEWS | 3 +++ Modules/_collectionsmodule.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index b8bcc21..0bfbd38 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -90,6 +90,9 @@ Core and Builtins Library ------- +- Issue #13015: Fix a possible reference leak in defaultdict.__repr__. + Patch by Suman Saha. + - Issue #13979: A bug in ctypes.util.find_library that caused the wrong library name to be returned has been fixed. diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index ea5f779..ccc3043 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1475,8 +1475,10 @@ defdict_repr(defdictobject *dd) { int status = Py_ReprEnter(dd->default_factory); if (status != 0) { - if (status < 0) + if (status < 0) { + Py_DECREF(baserepr); return NULL; + } defrepr = PyString_FromString("..."); } else -- cgit v0.12