[Python-checkins] cpython (2.7): Issue #13015: Fix a possible reference leak in defaultdict.__repr__.

antoine.pitrou python-checkins at python.org
Wed Feb 15 02:50:04 CET 2012


http://hg.python.org/cpython/rev/7611fb3e19c6
changeset:   74938:7611fb3e19c6
branch:      2.7
parent:      74931:be41abd74949
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Wed Feb 15 02:42:46 2012 +0100
summary:
  Issue #13015: Fix a possible reference leak in defaultdict.__repr__.
Patch by Suman Saha.

files:
  Misc/NEWS                    |  3 +++
  Modules/_collectionsmodule.c |  4 +++-
  2 files changed, 6 insertions(+), 1 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -90,6 +90,9 @@
 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
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1475,8 +1475,10 @@
     {
         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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list