Skip to content

Commit e01b04c

Browse files
gh-104614: Fix potential ref. leak in _testcapimodule/get_basic_static_type() (#105225)
1 parent 0dafc78 commit e01b04c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Modules/_testcapimodule.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -2671,13 +2671,15 @@ get_basic_static_type(PyObject *self, PyObject *args)
26712671
PyTypeObject *cls = &BasicStaticTypes[num_basic_static_types_used++];
26722672

26732673
if (base != NULL) {
2674-
cls->tp_base = (PyTypeObject *)Py_NewRef(base);
26752674
cls->tp_bases = Py_BuildValue("(O)", base);
26762675
if (cls->tp_bases == NULL) {
26772676
return NULL;
26782677
}
2678+
cls->tp_base = (PyTypeObject *)Py_NewRef(base);
26792679
}
26802680
if (PyType_Ready(cls) < 0) {
2681+
Py_DECREF(cls->tp_bases);
2682+
Py_DECREF(cls->tp_base);
26812683
return NULL;
26822684
}
26832685
return (PyObject *)cls;

0 commit comments

Comments
 (0)