[Python-checkins] GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989)

Fidget-Spinner webhook-mailer at python.org
Sun Jun 19 02:06:55 EDT 2022


https://github.com/python/cpython/commit/726448ebe15cd78e180c29c9858cb6c10a581524
commit: 726448ebe15cd78e180c29c9858cb6c10a581524
branch: main
author: Kumar Aditya <59607654+kumaraditya303 at users.noreply.github.com>
committer: Fidget-Spinner <kenjin at python.org>
date: 2022年06月19日T14:06:37+08:00
summary:
GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989)
files:
M Objects/typeobject.c
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 513055168062f..1236acdcd1930 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));
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /