From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sun, 19 Jun 2022 11:26:13 +0000 (+0530) Subject: GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989) (GH... X-Git-Tag: v3.10.6~159 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=beba1020a9d5b0350185b42fef6314cbe6c1d071;p=thirdparty%2FPython%2Fcpython.git GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989) (GH-93999) (cherry picked from commit 726448ebe15cd78e180c29c9858cb6c10a581524) --- diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 50f2742f676f..65a9475ab7d7 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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));