Skip to content

Commit e81dc29

Browse files
committed
Fixed memory leak in error branch of object_repr which may leak a reference to mod when type_name returns NULL. CID 715371
1 parent 3d46339 commit e81dc29

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Objects/typeobject.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2925,8 +2925,10 @@ object_repr(PyObject *self)
29252925
mod = NULL;
29262926
}
29272927
name = type_name(type, NULL);
2928-
if (name == NULL)
2928+
if (name == NULL) {
2929+
Py_XDECREF(mod);
29292930
return NULL;
2931+
}
29302932
if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "builtins"))
29312933
rtn = PyUnicode_FromFormat("<%U.%U object at %p>", mod, name, self);
29322934
else

0 commit comments

Comments
 (0)