[Python-checkins] Fix refleak in `super_descr_get` (#104408)

kumaraditya303 webhook-mailer at python.org
Fri May 12 03:11:35 EDT 2023


https://github.com/python/cpython/commit/a781484c8e9834538e5ee7b9e2e6bec7b679e033
commit: a781484c8e9834538e5ee7b9e2e6bec7b679e033
branch: main
author: Brandt Bucher <brandtbucher at microsoft.com>
committer: kumaraditya303 <59607654+kumaraditya303 at users.noreply.github.com>
date: 2023-05-12T12:41:27+05:30
summary:

Fix refleak in `super_descr_get` (#104408)

files:
M Objects/typeobject.c

diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index f40e197f8c23..a1ad5021c415 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -10277,8 +10277,10 @@ super_descr_get(PyObject *self, PyObject *obj, PyObject *type)
             return NULL;
         newobj = (superobject *)PySuper_Type.tp_new(&PySuper_Type,
                                                  NULL, NULL);
-        if (newobj == NULL)
+        if (newobj == NULL) {
+            Py_DECREF(obj_type);
             return NULL;
+        }
         newobj->type = (PyTypeObject*)Py_NewRef(su->type);
         newobj->obj = Py_NewRef(obj);
         newobj->obj_type = obj_type;



More information about the Python-checkins mailing list