diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-02-13 03:32:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-13 03:32:18 -0800 |
commit | ef20abed7f2ae0ba54b1d287f5fe601be80c1128 (patch) | |
tree | 8c744e5c7df5b8b200f85898b02f724247d870b0 /Objects | |
parent | 9b5a90b975ef32b261d60b8ec06504f4ffd00d63 (diff) | |
download | cpython-git-ef20abed7f2ae0ba54b1d287f5fe601be80c1128.tar.gz |
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
(cherry picked from commit d019bc8319ea35e93bf4baa38098ff1b57cd3ee5)
Co-authored-by: Oren Milman <orenmn@gmail.com>
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/descrobject.c | 8 | ||||
-rw-r--r-- | Objects/funcobject.c | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c index a2530184cd..6014039402 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1490,10 +1490,10 @@ property_init_impl(propertyobject *self, PyObject *fget, PyObject *fset, Py_XINCREF(fdel); Py_XINCREF(doc); - self->prop_get = fget; - self->prop_set = fset; - self->prop_del = fdel; - self->prop_doc = doc; + Py_XSETREF(self->prop_get, fget); + Py_XSETREF(self->prop_set, fset); + Py_XSETREF(self->prop_del, fdel); + Py_XSETREF(self->prop_doc, doc); self->getter_doc = 0; /* if no docstring given and the getter has one, use that one */ diff --git a/Objects/funcobject.c b/Objects/funcobject.c index d376f9cab9..241685d5b7 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -709,7 +709,7 @@ cm_init(PyObject *self, PyObject *args, PyObject *kwds) if (!PyArg_UnpackTuple(args, "classmethod", 1, 1, &callable)) return -1; Py_INCREF(callable); - cm->cm_callable = callable; + Py_XSETREF(cm->cm_callable, callable); return 0; } @@ -890,7 +890,7 @@ sm_init(PyObject *self, PyObject *args, PyObject *kwds) if (!PyArg_UnpackTuple(args, "staticmethod", 1, 1, &callable)) return -1; Py_INCREF(callable); - sm->sm_callable = callable; + Py_XSETREF(sm->sm_callable, callable); return 0; } |