Fixed possible reference leak to mod when type_name() returns NULL

This commit is contained in:
Christian Heimes 2012-09-10 03:01:16 +02:00
commit 455657961e
1 changed files with 3 additions and 1 deletions

View File

@ -691,8 +691,10 @@ type_repr(PyTypeObject *type)
mod = NULL; mod = NULL;
} }
name = type_qualname(type, NULL); name = type_qualname(type, NULL);
if (name == NULL) if (name == NULL) {
Py_XDECREF(mod);
return NULL; return NULL;
}
if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "builtins")) if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "builtins"))
rtn = PyUnicode_FromFormat("<class '%U.%U'>", mod, name); rtn = PyUnicode_FromFormat("<class '%U.%U'>", mod, name);