Skip to content

Commit beba102

Browse files
GH-93990: fix refcounting bug in add_subclass in typeobject.c (GH-93989) (GH-93999)
(cherry picked from commit 726448e)
1 parent f21b071 commit beba102

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Objects/typeobject.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -6400,8 +6400,11 @@ add_subclass(PyTypeObject *base, PyTypeObject *type)
64006400
PyObject *dict = base->tp_subclasses;
64016401
if (dict == NULL) {
64026402
base->tp_subclasses = dict = PyDict_New();
6403-
if (dict == NULL)
6403+
if (dict == NULL) {
6404+
Py_DECREF(key);
6405+
Py_DECREF(ref);
64046406
return -1;
6407+
}
64056408
}
64066409
assert(PyDict_CheckExact(dict));
64076410

0 commit comments

Comments
 (0)