bpo-36745: Fix a possible reference leak in PyObject_SetAttr() (GH-12993)
https://github.com/python/cpython/commit/896c6357f3267fe5dc5a33979f8cf46b0a7... commit: 896c6357f3267fe5dc5a33979f8cf46b0a74cfee branch: 3.7 author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> committer: GitHub <noreply@github.com> date: 2019-04-28T06:17:40-07:00 summary: bpo-36745: Fix a possible reference leak in PyObject_SetAttr() (GH-12993) https://bugs.python.org/issue36745 (cherry picked from commit e0dcb85b7d64153d1741698c04a6736c9669603a) Co-authored-by: Zackery Spytz <zspytz@gmail.com> files: M Objects/object.c diff --git a/Objects/object.c b/Objects/object.c index 420af9465b5c..8a3f8831d6e9 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -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;
participants (1)
-
Miss Islington (bot)