summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Houghton <alastair@coriolis-systems.com>2014-05-02 11:32:05 +0100
committerAlastair Houghton <alastair@coriolis-systems.com>2014-05-02 11:32:05 +0100
commita82da5d3cb03b06ab07ca48b4fcd46a253ae516e (patch)
tree995fa98a422a54b3ee95e2a8b9d768c74d60f9c8
parent8b67b396ecc5c818911640ffb993e8970601e88a (diff)
downloadnetifaces-a82da5d3cb03b06ab07ca48b4fcd46a253ae516e.tar.gz
Without this line, PyPy crashes. I guess we can't rely on the indirect reference via result (presumably due to some PyPy optimisation).
-rw-r--r--netifaces.c12
1 files changed, 12 insertions, 0 deletions
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 {