summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2016-07-07 06:26:32 (GMT)
committerBenjamin Peterson <benjamin@python.org>2016-07-07 06:26:32 (GMT)
commit27007dccec8ce20ee95e45492643bc1407326abc (patch)
treebd2ceaadee06abb456997da42416a6e455f0ffdf /Objects
parenta1fc45ae73f6c230ffb936db549ec225e19656af (diff)
downloadcpython-27007dccec8ce20ee95e45492643bc1407326abc.zip
cpython-27007dccec8ce20ee95e45492643bc1407326abc.tar.gz
cpython-27007dccec8ce20ee95e45492643bc1407326abc.tar.bz2
fix refleaks in PyDict_SetItem error cases (closes #27248)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 317334f..8c5c77e 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4509,8 +4509,10 @@ add_members(PyTypeObject *type, PyMemberDef *memb)
descr = PyDescr_NewMember(type, memb);
if (descr == NULL)
return -1;
- if (PyDict_SetItemString(dict, memb->name, descr) < 0)
+ if (PyDict_SetItemString(dict, memb->name, descr) < 0) {
+ Py_DECREF(descr);
return -1;
+ }
Py_DECREF(descr);
}
return 0;
@@ -4529,8 +4531,10 @@ add_getset(PyTypeObject *type, PyGetSetDef *gsp)
if (descr == NULL)
return -1;
- if (PyDict_SetItemString(dict, gsp->name, descr) < 0)
+ if (PyDict_SetItemString(dict, gsp->name, descr) < 0) {
+ Py_DECREF(descr);
return -1;
+ }
Py_DECREF(descr);
}
return 0;
@@ -7010,8 +7014,10 @@ add_operators(PyTypeObject *type)
descr = PyDescr_NewWrapper(type, p, *ptr);
if (descr == NULL)
return -1;
- if (PyDict_SetItem(dict, p->name_strobj, descr) < 0)
+ if (PyDict_SetItem(dict, p->name_strobj, descr) < 0) {
+ Py_DECREF(descr);
return -1;
+ }
Py_DECREF(descr);
}
}