summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-06-19 06:06:37 (GMT)
committerGitHub <noreply@github.com>2022-06-19 06:06:37 (GMT)
commit726448ebe15cd78e180c29c9858cb6c10a581524 (patch)
treedca1e7b05353711ab647074d9a8773669b2b73c1 /Objects
parent6066f450b91f1cbebf33a245c14e660052ccd90a (diff)
downloadcpython-726448ebe15cd78e180c29c9858cb6c10a581524.zip
cpython-726448ebe15cd78e180c29c9858cb6c10a581524.tar.gz
cpython-726448ebe15cd78e180c29c9858cb6c10a581524.tar.bz2
GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 5130551..1236acd 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));