Skip to content

Commit 896c635

Browse files
bpo-36745: Fix a possible reference leak in PyObject_SetAttr() (GH-12993)
https://bugs.python.org/issue36745 (cherry picked from commit e0dcb85) Co-authored-by: Zackery Spytz <[email protected]>
1 parent f5972cc commit 896c635

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Objects/object.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,10 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
10171017
}
10181018
if (tp->tp_setattr != NULL) {
10191019
const char *name_str = PyUnicode_AsUTF8(name);
1020-
if (name_str == NULL)
1020+
if (name_str == NULL) {
1021+
Py_DECREF(name);
10211022
return -1;
1023+
}
10221024
err = (*tp->tp_setattr)(v, (char *)name_str, value);
10231025
Py_DECREF(name);
10241026
return err;

0 commit comments

Comments
 (0)