From: Antoine Pitrou Date: Wed, 15 Feb 2012 01:42:46 +0000 (+0100) Subject: Issue #13015: Fix a possible reference leak in defaultdict.__repr__. X-Git-Tag: v3.2.3rc1~63 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f5f1fe0cb5dedf37098622de318656003dc5230d;p=thirdparty%2FPython%2Fcpython.git Issue #13015: Fix a possible reference leak in defaultdict.__repr__. Patch by Suman Saha. --- diff --git a/Misc/NEWS b/Misc/NEWS index 06ce40474d6c..0ef337c56bd3 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -113,6 +113,9 @@ Core and Builtins Library ------- +- Issue #13015: Fix a possible reference leak in defaultdict.__repr__. + Patch by Suman Saha. + - Issue #10287: nntplib now queries the server's CAPABILITIES first before sending MODE READER, and only sends it if not already in READER mode. Patch by Hynek Schlawack. diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 5545d1eff289..434315965ab5 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1401,8 +1401,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 = PyUnicode_FromString("..."); } else