diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-08 20:17:03 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-08 20:17:03 (GMT) |
commit | f93ed3fa67260fa0023a1360a37ab7e320550455 (patch) | |
tree | c99dddd7b3460544a57415d8f53ecbd097b975ec /Objects | |
parent | a7129d38edb1a9db17fbd8b40d9eaf135a857f8e (diff) | |
parent | 62a0d6ea402d18f528629c6e84ed6f46e7c0912a (diff) | |
download | cpython-f93ed3fa67260fa0023a1360a37ab7e320550455.zip cpython-f93ed3fa67260fa0023a1360a37ab7e320550455.tar.gz cpython-f93ed3fa67260fa0023a1360a37ab7e320550455.tar.bz2 |
Issue #16602: When a weakref's target was part of a long deallocation chain, the object could remain reachable through its weakref even though its refcount had dropped to zero.
Thanks to Eugene Toder for diagnosing and reporting the issue.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/weakrefobject.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index d3a4dd5..b49dcee 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -52,9 +52,8 @@ clear_weakref(PyWeakReference *self) { PyObject *callback = self->wr_callback; - if (PyWeakref_GET_OBJECT(self) != Py_None) { - PyWeakReference **list = GET_WEAKREFS_LISTPTR( - PyWeakref_GET_OBJECT(self)); + if (self->wr_object != Py_None) { + PyWeakReference **list = GET_WEAKREFS_LISTPTR(self->wr_object); if (*list == self) /* If 'self' is the end of the list (and thus self->wr_next == NULL) |