diff options
author | Erlend E. Aasland <erlend.aasland@protonmail.com> | 2023-06-02 16:44:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-02 16:44:24 (GMT) |
commit | e01b04c9075c6468ed57bc883693ec2a06a6dd8e (patch) | |
tree | 05dc89a60b1d7334fedea8607a016fbec7485a41 | |
parent | 0dafc785ee6629dbcb9bec6f7aee43a56cd0b26e (diff) | |
download | cpython-e01b04c9075c6468ed57bc883693ec2a06a6dd8e.zip cpython-e01b04c9075c6468ed57bc883693ec2a06a6dd8e.tar.gz cpython-e01b04c9075c6468ed57bc883693ec2a06a6dd8e.tar.bz2 |
gh-104614: Fix potential ref. leak in _testcapimodule/get_basic_static_type() (#105225)
-rw-r--r-- | Modules/_testcapimodule.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 38c2d1a..3acc757 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -2671,13 +2671,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; |