summaryrefslogtreecommitdiff
path: root/Objects/weakrefobject.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-12-08 21:15:26 +0100
committerAntoine Pitrou <solipsis@pitrou.net>2012-12-08 21:15:26 +0100
commit62a0d6ea402d18f528629c6e84ed6f46e7c0912a (patch)
tree72f36fc075688276626f59fb7138baf52d4077ed /Objects/weakrefobject.c
parent09974b4e9e8da3c9ba0469f4812e68cf9f700ffd (diff)
downloadcpython-git-62a0d6ea402d18f528629c6e84ed6f46e7c0912a.tar.gz
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.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index dae3c24f4a..8d571e65d1 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)