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

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


http://hg.python.org/cpython/rev/2b611280ff36
changeset:   78942:2b611280ff36
branch:      2.7
parent:      78939:bb0390c1d3d4
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
@@ -686,8 +686,10 @@
         mod = NULL;
     }
     name = type_name(type, NULL);
-    if (name == NULL)
+    if (name == NULL) {
+        Py_XDECREF(mod);
         return NULL;
+    }
 
     if (type->tp_flags & Py_TPFLAGS_HEAPTYPE)
         kind = "class";

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


More information about the Python-checkins mailing list