[Python-checkins] cpython (3.2): 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:40 CEST 2012


http://hg.python.org/cpython/rev/302561c9387a
changeset:   78964:302561c9387a
branch:      3.2
parent:      78962:4a343636c8ca
user:        Christian Heimes <christian at cheimes.de>
date:        Mon Sep 10 16:57:36 2012 +0200
summary:
  Fixed memory leak in error branch of object_repr which may leak a reference to mod when type_name 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
@@ -2925,8 +2925,10 @@
         mod = NULL;
     }
     name = type_name(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