[Python-checkins] cpython (merge 3.2 -> default): Fixed memory leak in error branch of object_repr which may leak a reference to

christian.heimes python-checkins at python.org
Mon Sep 10 17:01:43 CEST 2012


http://hg.python.org/cpython/rev/f9b95ffd24ce
changeset:   78966:f9b95ffd24ce
parent:      78963:2c9f1a578861
parent:      78964:302561c9387a
user:        Christian Heimes <christian at cheimes.de>
date:        Mon Sep 10 17:00:30 2012 +0200
summary:
  Fixed memory leak in error branch of object_repr which may leak a reference to mod when type_qualname returns NULL. CID 715371

files:
  Objects/typeobject.c |  4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)


diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3130,8 +3130,10 @@
         mod = NULL;
     }
     name = type_qualname(type, NULL);
-    if (name == NULL)
+    if (name == NULL) {
+        Py_XDECREF(mod);
         return NULL;
+    }
     if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "builtins"))
         rtn = PyUnicode_FromFormat("<%U.%U object at %p>", mod, name, self);
     else

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


More information about the Python-checkins mailing list