mirror of
https://github.com/python/cpython.git
synced 2026-01-04 14:32:21 +00:00
fix refleaks in PyDict_SetItem error cases (closes #27248)
This commit is contained in:
parent
a1fc45ae73
commit
27007dccec
1 changed files with 9 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue