mirror of https://github.com/python/cpython
Fixed possible reference leak to mod when type_name() returns NULL
This commit is contained in:
parent
d5a88044a3
commit
a0e7e41cba
|
@ -647,8 +647,10 @@ type_repr(PyTypeObject *type)
|
||||||
mod = NULL;
|
mod = NULL;
|
||||||
}
|
}
|
||||||
name = type_name(type, NULL);
|
name = type_name(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);
|
||||||
|
|
Loading…
Reference in New Issue