mirror of https://github.com/python/cpython
GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989)
This commit is contained in:
parent
6066f450b9
commit
726448ebe1
|
@ -6671,9 +6671,12 @@ 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));
|
||||
|
||||
int result = PyDict_SetItem(subclasses, key, ref);
|
||||
|
|
Loading…
Reference in New Issue