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,8 +6671,11 @@ add_subclass(PyTypeObject *base, PyTypeObject *type)
|
||||||
PyObject *subclasses = base->tp_subclasses;
|
PyObject *subclasses = base->tp_subclasses;
|
||||||
if (subclasses == NULL) {
|
if (subclasses == NULL) {
|
||||||
base->tp_subclasses = subclasses = PyDict_New();
|
base->tp_subclasses = subclasses = PyDict_New();
|
||||||
if (subclasses == NULL)
|
if (subclasses == NULL) {
|
||||||
|
Py_DECREF(key);
|
||||||
|
Py_DECREF(ref);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert(PyDict_CheckExact(subclasses));
|
assert(PyDict_CheckExact(subclasses));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue