Skip to content

Commit

Permalink
pythonGH-93990: fix refcounting bug in add_subclass in `typeobject.…
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaraditya303 authored Jun 19, 2022
1 parent 6066f45 commit 726448e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -6671,8 +6671,11 @@ add_subclass(PyTypeObject *base, PyTypeObject *type)
PyObject *subclasses = base->tp_subclasses;
if (subclasses == NULL) {
base->tp_subclasses = subclasses = PyDict_New();
if (subclasses == NULL)
if (subclasses == NULL) {
Py_DECREF(key);
Py_DECREF(ref);
return -1;
}
}
assert(PyDict_CheckExact(subclasses));

Expand Down

0 comments on commit 726448e

Please sign in to comment.