summaryrefslogtreecommitdiff
path: root/netifaces.c
diff options
context:
space:
mode:
authorAlastair Houghton <alastair@alastairs-place.net>2014-05-02 11:32:05 +0100
committerAlastair Houghton <alastair@alastairs-place.net>2014-05-02 11:32:05 +0100
commit23acfcf42339d95c04953f7c7c57f391f0f809a6 (patch)
tree995fa98a422a54b3ee95e2a8b9d768c74d60f9c8 /netifaces.c
parentd36d54ae774eb518eac391fdcf376dd596252546 (diff)
downloadnetifaces-git-23acfcf42339d95c04953f7c7c57f391f0f809a6.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).
Diffstat (limited to 'netifaces.c')
-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 {