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:
Miss Islington (bot) 2019-04-28 06:17:40 -07:00 committed by GitHub
parent f5972cc0c9
commit 896c6357f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;