diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-04-28 06:17:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-28 06:17:40 -0700 |
commit | 896c6357f3267fe5dc5a33979f8cf46b0a74cfee (patch) | |
tree | 8607f0b9fed137c282f0645b4083b47f4dc44f0d /Objects | |
parent | f5972cc0c9a8e3315207e2d67534f330d619af4e (diff) | |
download | cpython-git-896c6357f3267fe5dc5a33979f8cf46b0a74cfee.tar.gz |
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>
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/object.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c index 420af9465b..8a3f8831d6 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; |