Skip to content

Commit 15c8838

Browse files
GH-93990: fix refcounting bug in add_subclass in typeobject.c (GH-93989)
(cherry picked from commit 726448e) Co-authored-by: Kumar Aditya <[email protected]>
1 parent 0c826d3 commit 15c8838

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
@@ -6512,8 +6512,11 @@ add_subclass(PyTypeObject *base, PyTypeObject *type)
65126512
PyObject *subclasses = base->tp_subclasses;
65136513
if (subclasses == NULL) {
65146514
base->tp_subclasses = subclasses = PyDict_New();
6515-
if (subclasses == NULL)
6515+
if (subclasses == NULL) {
6516+
Py_DECREF(key);
6517+
Py_DECREF(ref);
65166518
return -1;
6519+
}
65176520
}
65186521
assert(PyDict_CheckExact(subclasses));
65196522

0 commit comments

Comments
 (0)