diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-09-22 19:46:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-22 19:46:07 +0200 |
commit | 95aea67adb89f7207322ceb3bf91af79e7fa77e9 (patch) | |
tree | 3a24bfa36f63948aa5f2a5b2d8d3058389db5d75 /psutil/_psutil_linux.c | |
parent | c913480621da83b9cc78ade2217a81490142a604 (diff) | |
parent | f6269a6321a41bf6e9490425e1549e24cce225c7 (diff) | |
download | psutil-95aea67adb89f7207322ceb3bf91af79e7fa77e9.tar.gz |
Merge pull request #825 from hardikar/master
Fix possible double close and use of unopened socket
Diffstat (limited to 'psutil/_psutil_linux.c')
-rw-r--r-- | psutil/_psutil_linux.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c index 19fd14b9..5f6b6616 100644 --- a/psutil/_psutil_linux.c +++ b/psutil/_psutil_linux.c @@ -402,7 +402,7 @@ psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) { #else long value = PyInt_AsLong(item); #endif - if (value == -1 && PyErr_Occurred()) + if (value == -1 || PyErr_Occurred()) goto error; CPU_SET(value, &cpu_set); } @@ -536,17 +536,17 @@ psutil_net_if_stats(PyObject* self, PyObject* args) { } } - close(sock); py_retlist = Py_BuildValue("[Oiii]", py_is_up, duplex, speed, mtu); if (!py_retlist) goto error; + close(sock); Py_DECREF(py_is_up); return py_retlist; error: - Py_XDECREF(py_is_up); - if (sock != 0) + if (sock != -1) close(sock); + Py_XDECREF(py_is_up); PyErr_SetFromErrno(PyExc_OSError); return NULL; } |