]> granicus.if.org Git - python/commitdiff
Issue #13015: Fix a possible reference leak in defaultdict.__repr__.
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 15 Feb 2012 01:42:46 +0000 (02:42 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 15 Feb 2012 01:42:46 +0000 (02:42 +0100)
Patch by Suman Saha.

Misc/NEWS
Modules/_collectionsmodule.c

index 06ce40474d6cdb832cc6892fe9ed59188fffb837..0ef337c56bd3e732edff2e2ae269c5b01d875b6b 100644 (file)
--- 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.
index 5545d1eff2898b62127797dfd0e978bb1c44c81d..434315965ab5a64535d473fc8aea014963a3b012 100644 (file)
@@ -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