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

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


http://hg.python.org/cpython/rev/517aa5576ae3
changeset:   78941:517aa5576ae3
parent:      78938:033b409f7cd6
parent:      78940:9f4e6c0c18e6
user:        Christian Heimes <christian at cheimes.de>
date:        Mon Sep 10 03:01:16 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
@@ -691,8 +691,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("<class '%U.%U'>", mod, name);

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


More information about the Python-checkins mailing list