mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
Fixed memory leak in error branch of object_repr which may leak a reference to mod when type_name returns NULL. CID 715371
This commit is contained in:
parent
3d463393bb
commit
e81dc296f2
1 changed files with 3 additions and 1 deletions
|
|
@ -2925,8 +2925,10 @@ object_repr(PyObject *self)
|
||||||
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("<%U.%U object at %p>", mod, name, self);
|
rtn = PyUnicode_FromFormat("<%U.%U object at %p>", mod, name, self);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue