summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-01-06 11:34:08 -0800
committerGiampaolo Rodola <g.rodola@gmail.com>2020-01-06 11:34:08 -0800
commit2c9b0be14ee2228315b3a79663912d58c2aa5527 (patch)
tree568cb6d7df35df99608574ca6c545758f81bde44
parent9d029a0a19a8dbcfb8fd5913a02eb7755836523e (diff)
downloadpsutil-2c9b0be14ee2228315b3a79663912d58c2aa5527.tar.gz
Win: fix segfault cause by FREE/MALLOC macros
-rw-r--r--psutil/_pswindows.py1
-rw-r--r--psutil/arch/windows/net.c6
2 files changed, 4 insertions, 3 deletions
diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py
index afef1110..772c38c1 100644
--- a/psutil/_pswindows.py
+++ b/psutil/_pswindows.py
@@ -328,6 +328,7 @@ def cpu_freq():
_loadavg_inititialized = False
+
def getloadavg():
"""Return the number of processes in the system run queue averaged
over the last 1, 5, and 15 minutes respectively as a tuple"""
diff --git a/psutil/arch/windows/net.c b/psutil/arch/windows/net.c
index cb9c1564..fc083540 100644
--- a/psutil/arch/windows/net.c
+++ b/psutil/arch/windows/net.c
@@ -18,13 +18,13 @@
static PIP_ADAPTER_ADDRESSES
psutil_get_nic_addresses() {
// allocate a 15 KB buffer to start with
- ULONG outBufLen = 15000;
+ int outBufLen = 15000;
DWORD dwRetVal = 0;
ULONG attempts = 0;
PIP_ADAPTER_ADDRESSES pAddresses = NULL;
do {
- pAddresses = (IP_ADAPTER_ADDRESSES *) MALLOC(outBufLen);
+ pAddresses = (IP_ADAPTER_ADDRESSES *) malloc(outBufLen);
if (pAddresses == NULL) {
PyErr_NoMemory();
return NULL;
@@ -33,7 +33,7 @@ psutil_get_nic_addresses() {
dwRetVal = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, pAddresses,
&outBufLen);
if (dwRetVal == ERROR_BUFFER_OVERFLOW) {
- FREE(pAddresses);
+ free(pAddresses);
pAddresses = NULL;
}
else {