8000 bpo-36745: Fix a possible reference leak in PyObject_SetAttr() (GH-12… · python/cpython@e0dcb85 · GitHub
[go: up one dir, main page]

Skip to content

Commit e0dcb85

Browse files
ZackerySpytzmiss-islington
authored andcommitted
bpo-36745: Fix a possible reference leak in PyObject_SetAttr() (GH-12993)
https://bugs.python.org/issue36745
1 parent da63b32 commit e0dcb85

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
@@ -1044,8 +1044,10 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
10441044
}
10451045
if (tp->tp_setattr != NULL) {
10461046
const char *name_str = PyUnicode_AsUTF8(name);
1047-
if (name_str == NULL)
1047+
if (name_str == NULL) {
1048+
Py_DECREF(name);
10481049
return -1;
1050+
}
10491051
err = (*tp->tp_setattr)(v, (char *)name_str, value);
10501052
Py_DECREF(name);
10511053
return err;

0 commit comments

Comments
 (0)
0