From a82da5d3cb03b06ab07ca48b4fcd46a253ae516e Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Fri, 2 May 2014 11:32:05 +0100 Subject: Without this line, PyPy crashes. I guess we can't rely on the indirect reference via result (presumably due to some PyPy optimisation). --- netifaces.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/netifaces.c b/netifaces.c index 51c126a..36bacf3 100644 --- a/netifaces.c +++ b/netifaces.c @@ -1253,6 +1253,9 @@ gateways (PyObject *self) PyDict_SetItemString (result, "default", defaults); Py_DECREF(defaults); + /* This prevents a crash on PyPy */ + defaults = PyDict_GetItemString (result, "default"); + for (n = 0; n < table->NumEntries; ++n) { MIB_IFROW ifRow; PyObject *ifname; @@ -1382,6 +1385,9 @@ gateways (PyObject *self) PyDict_SetItemString (result, "default", defaults); Py_DECREF(defaults); + /* This prevents a crash on PyPy */ + defaults = PyDict_GetItemString (result, "default"); + for (n = 0; n < table->dwNumEntries; ++n) { MIB_IFROW ifRow; PyObject *ifname; @@ -1473,6 +1479,9 @@ gateways (PyObject *self) PyDict_SetItemString (result, "default", defaults); Py_DECREF (defaults); + /* This prevents a crash on PyPy */ + defaults = PyDict_GetItemString (result, "default"); + msgbuf = pmsg = (struct routing_msg *)malloc (bufsize); if (!pmsg) { @@ -1700,6 +1709,9 @@ gateways (PyObject *self) PyDict_SetItemString (result, "default", defaults); Py_DECREF (defaults); + /* This prevents a crash on PyPy */ + defaults = PyDict_GetItemString (result, "default"); + /* Remembering that the routing table may change while we're reading it, we need to do this in a loop until we succeed. */ do { -- cgit v1.2.1