Skip to content

Commit

Permalink
GH-93990: fix refcounting bug in add_subclass in typeobject.c (GH…
Browse files Browse the repository at this point in the history
…-93989) (GH-93999)

(cherry picked from commit 726448e)
  • Loading branch information
kumaraditya303 authored Jun 19, 2022
1 parent f21b071 commit beba102
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 @@ -6400,8 +6400,11 @@ add_subclass(PyTypeObject *base, PyTypeObject *type)
PyObject *dict = base->tp_subclasses;
if (dict == NULL) {
base->tp_subclasses = dict = PyDict_New();
if (dict == NULL)
if (dict == NULL) {
Py_DECREF(key);
Py_DECREF(ref);
return -1;
}
}
assert(PyDict_CheckExact(dict));

Expand Down

0 comments on commit beba102

Please sign in to comment.