[Python-checkins] gh-104614: Fix potential ref. leak in _testcapimodule/get_basic_static_type() (#105225)
erlend-aasland
webhook-mailer at python.org
Fri Jun 2 12:44:31 EDT 2023
https://github.com/python/cpython/commit/e01b04c9075c6468ed57bc883693ec2a06a6dd8e
commit: e01b04c9075c6468ed57bc883693ec2a06a6dd8e
branch: main
author: Erlend E. Aasland <erlend.aasland at protonmail.com>
committer: erlend-aasland <erlend.aasland at protonmail.com>
date: 2023-06-02T18:44:24+02:00
summary:
gh-104614: Fix potential ref. leak in _testcapimodule/get_basic_static_type() (#105225)
files:
M Modules/_testcapimodule.c
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 38c2d1a91af3..3acc7575cfe8 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;
More information about the Python-checkins
mailing list