mirror of
https://github.com/python/cpython.git
synced 2026-04-22 03:41:08 +00:00
bpo-36745: Fix a possible reference leak in PyObject_SetAttr() (GH-12993)
https://bugs.python.org/issue36745
(cherry picked from commit e0dcb85b7d)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
parent
f5972cc0c9
commit
896c6357f3
1 changed files with 3 additions and 1 deletions
|
|
@ -1017,8 +1017,10 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
|
|||
}
|
||||
if (tp->tp_setattr != NULL) {
|
||||
const char *name_str = PyUnicode_AsUTF8(name);
|
||||
if (name_str == NULL)
|
||||
if (name_str == NULL) {
|
||||
Py_DECREF(name);
|
||||
return -1;
|
||||
}
|
||||
err = (*tp->tp_setattr)(v, (char *)name_str, value);
|
||||
Py_DECREF(name);
|
||||
return err;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue