Skip to content

Commit

Permalink
[3.12] gh-104614: Fix potential ref. leak in _testcapimodule/get_basi…
Browse files Browse the repository at this point in the history
…c_static_type() (GH-105225) (#105248)

(cherry picked from commit e01b04c)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
  • Loading branch information
miss-islington and erlend-aasland committed Jun 2, 2023
1 parent 00fe618 commit 72d5dfa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2658,13 +2658,15 @@ get_basic_static_type(PyObject *self, PyObject *args)
PyTypeObject *cls = &BasicStaticTypes[num_basic_static_types_used++];

if (base != NULL) {
cls->tp_base = (PyTypeObject *)Py_NewRef(base);
cls->tp_bases = Py_BuildValue("(O)", base);
if (cls->tp_bases == NULL) {
return NULL;
}
cls->tp_base = (PyTypeObject *)Py_NewRef(base);
}
if (PyType_Ready(cls) < 0) {
Py_DECREF(cls->tp_bases);
Py_DECREF(cls->tp_base);
return NULL;
}
return (PyObject *)cls;
Expand Down

0 comments on commit 72d5dfa

Please sign in to comment.