diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-08 20:15:26 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-08 20:15:26 (GMT) |
commit | d38c990bb73f47a6293e5f783131b709e7ef0982 (patch) | |
tree | 5dab3e90b67c7aa1e5b8a8ba3e10338bd7dfe188 /Objects/weakrefobject.c | |
parent | bd5279ea247e46d4bf88d1b1b306060e479e227f (diff) | |
download | cpython-d38c990bb73f47a6293e5f783131b709e7ef0982.zip cpython-d38c990bb73f47a6293e5f783131b709e7ef0982.tar.gz cpython-d38c990bb73f47a6293e5f783131b709e7ef0982.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/weakrefobject.c')
-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 7b943b0..99bf42b 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) |