summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-06-19 11:26:13 (GMT)
committerGitHub <noreply@github.com>2022-06-19 11:26:13 (GMT)
commitbeba1020a9d5b0350185b42fef6314cbe6c1d071 (patch)
treee0d13be5d390a2ad4895ae2d88beb53f7768c84a /Objects
parentf21b0717299a4314b0435b3c5575981732db15be (diff)
downloadcpython-beba1020a9d5b0350185b42fef6314cbe6c1d071.zip
cpython-beba1020a9d5b0350185b42fef6314cbe6c1d071.tar.gz
cpython-beba1020a9d5b0350185b42fef6314cbe6c1d071.tar.bz2
GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989) (GH-93999)
(cherry picked from commit 726448ebe15cd78e180c29c9858cb6c10a581524)
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 50f2742..65a9475 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));