bpo-29347: Fix possibly dereferencing undefined pointers when creating weakref objects (#128) (#186)
diff --git a/Misc/NEWS b/Misc/NEWS
index b631fde..0fed99b 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.
+
- bpo-29438: Fixed use-after-free problem in key sharing dict.
- Issue #29319: Prevent RunMainFromImporter overwriting sys.path[0].
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index ab6b235..9ca386d 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;
}