summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-04-28 06:17:40 -0700
committerGitHub <noreply@github.com>2019-04-28 06:17:40 -0700
commit896c6357f3267fe5dc5a33979f8cf46b0a74cfee (patch)
tree8607f0b9fed137c282f0645b4083b47f4dc44f0d /Objects
parentf5972cc0c9a8e3315207e2d67534f330d619af4e (diff)
downloadcpython-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.c4
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;