summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2015-08-26 02:26:57 -0700
committerGiampaolo Rodola <g.rodola@gmail.com>2015-08-26 02:26:57 -0700
commit6ae9568fd52945f26c2f71681166461c528e460a (patch)
treeec9de1cfdfe825eb5dfc399e4218110a82964736
parent3091db092c10b60a3f37ca228f274d66815f846a (diff)
parent58211221f70071531585665fcfa8ba4f21645d5f (diff)
downloadpsutil-6ae9568fd52945f26c2f71681166461c528e460a.tar.gz
Merge branch 'master' into 655-windows-unicode
-rw-r--r--CREDITS4
-rw-r--r--HISTORY.rst2
-rw-r--r--psutil/_psutil_windows.c35
3 files changed, 24 insertions, 17 deletions
diff --git a/CREDITS b/CREDITS
index 98adf16c..62fb347e 100644
--- a/CREDITS
+++ b/CREDITS
@@ -317,3 +317,7 @@ I: 664
N: Steven Winfield
W: https://github.com/stevenwinfield
I: 672
+
+N: sk6249
+W: https://github.com/sk6249
+I: 670
diff --git a/HISTORY.rst b/HISTORY.rst
index b4405f2b..def4bb3e 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -17,6 +17,8 @@ Bug tracker at https://github.com/giampaolo/psutil/issues
**Bug fixes**
+- #670: [Windows] segfgault of net_if_addrs() in case of non-ASCII NIC names.
+ (patch by sk6249)
- #672: [Windows] compilation fails if using Windows SDK v8.0. (patch by
Steven Winfield)
diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c
index d3faf50e..504f8ccc 100644
--- a/psutil/_psutil_windows.c
+++ b/psutil/_psutil_windows.c
@@ -2203,8 +2203,9 @@ psutil_net_io_counters(PyObject *self, PyObject *args) {
if (!py_nic_info)
goto error;
- py_nic_name = PyUnicode_FromWideChar(pCurrAddresses->FriendlyName,
- wcslen(pCurrAddresses->FriendlyName));
+ py_nic_name = PyUnicode_FromWideChar(
+ pCurrAddresses->FriendlyName,
+ wcslen(pCurrAddresses->FriendlyName));
if (py_nic_name == NULL)
goto error;
@@ -2850,7 +2851,7 @@ psutil_net_if_addrs(PyObject *self, PyObject *args) {
PyObject *py_tuple = NULL;
PyObject *py_address = NULL;
PyObject *py_mac_address = NULL;
- PyObject *py_nic_name = NULL;
+ PyObject *py_nic_name = NULL;
if (py_retlist == NULL)
return NULL;
@@ -2862,12 +2863,12 @@ psutil_net_if_addrs(PyObject *self, PyObject *args) {
while (pCurrAddresses) {
pUnicast = pCurrAddresses->FirstUnicastAddress;
-
- py_nic_name = NULL;
- py_nic_name = PyUnicode_FromWideChar(pCurrAddresses->FriendlyName,
- wcslen(pCurrAddresses->FriendlyName));
- if (py_nic_name == NULL)
- goto error;
+
+ py_nic_name = NULL;
+ py_nic_name = PyUnicode_FromWideChar(pCurrAddresses->FriendlyName,
+ wcslen(pCurrAddresses->FriendlyName));
+ if (py_nic_name == NULL)
+ goto error;
// MAC address
if (pCurrAddresses->PhysicalAddressLength != 0) {
@@ -2971,7 +2972,7 @@ psutil_net_if_addrs(PyObject *self, PyObject *args) {
pUnicast = pUnicast->Next;
}
}
- Py_DECREF(py_nic_name);
+ Py_DECREF(py_nic_name);
pCurrAddresses = pCurrAddresses->Next;
}
@@ -2984,7 +2985,7 @@ error:
Py_DECREF(py_retlist);
Py_XDECREF(py_tuple);
Py_XDECREF(py_address);
- Py_XDECREF(py_nic_name);
+ Py_XDECREF(py_nic_name);
return NULL;
}
@@ -3065,14 +3066,14 @@ psutil_net_if_stats(PyObject *self, PyObject *args) {
}
// is up?
- if((pIfRow->dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED ||
+ if((pIfRow->dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED ||
pIfRow->dwOperStatus == MIB_IF_OPER_STATUS_OPERATIONAL) &&
pIfRow->dwAdminStatus == 1 ) {
- py_is_up = Py_True;
- }
- else {
- py_is_up = Py_False;
- }
+ py_is_up = Py_True;
+ }
+ else {
+ py_is_up = Py_False;
+ }
Py_INCREF(py_is_up);
py_ifc_info = Py_BuildValue(