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

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


http://hg.python.org/cpython/rev/86adb5c7a9d4
changeset:   74936:86adb5c7a9d4
branch:      3.2
parent:      74933:a7f1ffd741d6
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
@@ -113,6 +113,9 @@
 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
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1401,8 +1401,10 @@
     {
         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

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


More information about the Python-checkins mailing list