bpo-36745: Fix a possible reference leak in PyObject_SetAttr() (GH-12993)

https://bugs.python.org/issue36745
This commit is contained in:
Zackery Spytz 2019-04-28 06:58:52 -06:00 committed by Miss Islington (bot)
parent da63b321f6
commit e0dcb85b7d
1 changed files with 3 additions and 1 deletions

View File

@ -1044,8 +1044,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;