From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sun, 19 Jun 2022 06:06:37 +0000 (+0530) Subject: GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989) X-Git-Tag: v3.12.0a1~1208 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=726448ebe15cd78e180c29c9858cb6c10a581524;p=thirdparty%2FPython%2Fcpython.git GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989) --- diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 513055168062..1236acdcd193 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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));