summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-06-02 17:09:51 (GMT)
committerGitHub <noreply@github.com>2023-06-02 17:09:51 (GMT)
commit72d5dfaa8f475498644035839f5a6469db486407 (patch)
treee28027fabfd64e01f406f3b294b78961c6ec8163 /Modules
parent00fe6186cb8bb5de9ab1604521dfd2584a487545 (diff)
downloadcpython-72d5dfaa8f475498644035839f5a6469db486407.zip
cpython-72d5dfaa8f475498644035839f5a6469db486407.tar.gz
cpython-72d5dfaa8f475498644035839f5a6469db486407.tar.bz2
[3.12] gh-104614: Fix potential ref. leak in _testcapimodule/get_basic_static_type() (GH-105225) (#105248)
(cherry picked from commit e01b04c9075c6468ed57bc883693ec2a06a6dd8e) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testcapimodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 3caaca3..b8ad00a 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -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;