]> 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 b8bcc211bf2e8a8595766a07b972258b77078815..0bfbd3861ab2abc9ec87e2e75841460de004dd57 100644 (file)
--- 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.
 
index ea5f7795dc93bce8b6ac434655ae4de7ec1d7926..ccc3043cae01d1becec696b927cfb17bd6255e28 100644 (file)
@@ -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