]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989) (GH...
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Sun, 19 Jun 2022 11:26:13 +0000 (16:56 +0530)
committerGitHub <noreply@github.com>
Sun, 19 Jun 2022 11:26:13 +0000 (19:26 +0800)
(cherry picked from commit 726448ebe15cd78e180c29c9858cb6c10a581524)

Objects/typeobject.c

index 50f2742f676f68f0b7083d42a0ee5fc4eee3358d..65a9475ab7d7fe4737c58c7c3c3a05cef0f76f4c 100644 (file)
@@ -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));