From 0400bb4e85a990d3a8700518c939b78f381cb53d Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Mon, 20 Feb 2017 12:50:57 +0800 Subject: [PATCH] backport to 2.7 --- Misc/NEWS | 3 +++ Objects/weakrefobject.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index f0ba8c621345bf..8726996a4bc18c 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 2.7.14? 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 c8b982fcd59ce8..2eb4fe0b17fbf0 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -24,6 +24,8 @@ init_weakref(PyWeakReference *self, PyObject *ob, PyObject *callback) { self->hash = -1; self->wr_object = ob; + self->wr_prev = NULL; + self->wr_next = NULL; Py_XINCREF(callback); self->wr_callback = callback; }