]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989)
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Sun, 19 Jun 2022 06:06:37 +0000 (11:36 +0530)
committerGitHub <noreply@github.com>
Sun, 19 Jun 2022 06:06:37 +0000 (14:06 +0800)
Objects/typeobject.c

index 513055168062f192c5e52be6f01ce327487d91f6..1236acdcd1930bef2b2ea26120211e44d1a52f90 100644 (file)
@@ -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));