diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2015-02-09 17:22:41 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2015-02-09 17:22:41 +0100 |
commit | 88ceaf9c27c4b4fe1ace97b0e65f02ea7aab424c (patch) | |
tree | 24fdc3ee9a36ed9ff1a3f850a3ee435feef33ef5 | |
parent | 734208781900e194878a712e9973859f843d8283 (diff) | |
download | psutil-88ceaf9c27c4b4fe1ace97b0e65f02ea7aab424c.tar.gz |
solve potential memory leak
-rw-r--r-- | docs/index.rst | 4 | ||||
-rw-r--r-- | psutil/_psutil_linux.c | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/docs/index.rst b/docs/index.rst index 92d7fe73..bbed0287 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -18,9 +18,9 @@ Quick links * `Home page <https://github.com/giampaolo/psutil>`__ * `Blog <http://grodola.blogspot.com/search/label/psutil>`__ -* `Download <https://pypi.python.org/pypi?:action=display&name=psutil#downloads>`__ * `Forum <http://groups.google.com/group/psutil/topics>`__ -- `Installation <https://github.com/giampaolo/psutil/blob/master/INSTALL.rst>`_ +* `Download <https://pypi.python.org/pypi?:action=display&name=psutil#downloads>`__ +* `Installation <https://github.com/giampaolo/psutil/blob/master/INSTALL.rst>`_ * `What's new <https://github.com/giampaolo/psutil/blob/master/HISTORY.rst>`__ About diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c index 98255445..921e03fe 100644 --- a/psutil/_psutil_linux.c +++ b/psutil/_psutil_linux.c @@ -301,7 +301,6 @@ psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) #else PyObject *cpu_num = PyInt_FromLong(cpu); #endif - --count; if (cpu_num == NULL) goto error; if (PyList_Append(res, cpu_num)) { @@ -309,6 +308,7 @@ psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) goto error; } Py_DECREF(cpu_num); + --count; } } CPU_FREE(mask); @@ -346,6 +346,8 @@ psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) } py_retlist = PyList_New(0); + if (py_retlist == NULL) + goto error; for (i = 0; i < CPU_SETSIZE; ++i) { if (CPU_ISSET(i, &cpuset)) { py_cpu_num = Py_BuildValue("i", i); @@ -353,6 +355,7 @@ psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) goto error; if (PyList_Append(py_retlist, py_cpu_num)) goto error; + Py_DECREF(py_cpu_num); } } |