bpo-29347: Fix possibly dereferencing undefined pointers when creating weakref objects (#128) (#187)
diff --git a/Misc/NEWS b/Misc/NEWS
index f0ba8c6..8726996 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- bpo-29347: Fixed possibly dereferencing undefined pointers
+ when creating weakref objects.
+
- Issue #14376: Allow sys.exit to accept longs as well as ints. Patch
by Gareth Rees.
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index c8b982f..2eb4fe0 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -24,6 +24,8 @@
{
self->hash = -1;
self->wr_object = ob;
+ self->wr_prev = NULL;
+ self->wr_next = NULL;
Py_XINCREF(callback);
self->wr_callback = callback;
}