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


http://hg.python.org/cpython/rev/a1671c795934
changeset:   78965:a1671c795934
branch:      2.7
parent:      78956:6d0c54b99ca9
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
@@ -2984,8 +2984,10 @@
         mod = NULL;
     }
     name = type_name(type, NULL);
-    if (name == NULL)
+    if (name == NULL) {
+        Py_XDECREF(mod);
         return NULL;
+    }
     if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__"))
         rtn = PyString_FromFormat("<%s.%s object at %p>",
                                   PyString_AS_STRING(mod),

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


More information about the Python-checkins mailing list