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
…c` (pythonGH-93989)

(cherry picked from commit 726448e)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
  • Loading branch information
miss-islington and kumaraditya303 authored Jun 19, 2022
1 parent 0c826d3 commit 15c8838
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 @@ -6512,8 +6512,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 15c8838

Please sign in to comment.