[Python-checkins] cpython (3.2): Fixed possible reference leak to mod when type_name() returns NULL

christian.heimes python-checkins at python.org
Mon Sep 10 03:02:04 CEST 2012


http://hg.python.org/cpython/rev/9f4e6c0c18e6
changeset:   78940:9f4e6c0c18e6
branch:      3.2
parent:      78937:bbc580e004d7
user:        Christian Heimes <christian at cheimes.de>
date:        Mon Sep 10 03:00:14 2012 +0200
summary:
  Fixed possible reference leak to mod when type_name() returns NULL

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
@@ -647,8 +647,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("<class '%U.%U'>", mod, name);

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


More information about the Python-checkins mailing list