diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2019-02-25 18:35:57 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2019-02-25 18:35:57 +0100 |
commit | 842a50538fb518291079ab5f245cca4c63813cb2 (patch) | |
tree | 3448626f80cc8e25e604dcf14f48efe2b4d55ddc | |
parent | a740a03e9de7492e20d98426b7e78eb805691890 (diff) | |
download | psutil-842a50538fb518291079ab5f245cca4c63813cb2.tar.gz |
#1411 / BSD / Process() init: use Py_INCREF() around process name pyobj and avoid segfault
-rw-r--r-- | HISTORY.rst | 2 | ||||
-rw-r--r-- | psutil/_psutil_bsd.c | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/HISTORY.rst b/HISTORY.rst index e0ea1f1d..013645bd 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -21,6 +21,8 @@ XXXX-XX-XX - 1394_: [Windows] Process name() and exe() may erronously return "Registry". QueryFullProcessImageNameW is now used instead of GetProcessImageFileNameW in order to prevent that. +- 1411_: [BSD] lack of Py_DECREF could cause segmentation fault on process + instantiation. - 1419_: [Windows] Process.environ() raises NotImplementedError when querying a 64-bit process in 32-bit-WoW mode. Now it raises AccessDenied. - 1427_: [OSX] Process cmdline() and environ() may erroneously raise OSError diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c index 073ff02d..efb933fb 100644 --- a/psutil/_psutil_bsd.c +++ b/psutil/_psutil_bsd.c @@ -223,6 +223,7 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) { PyErr_Clear(); py_name = Py_None; } + // Py_INCREF(py_name); // Calculate memory. #ifdef PSUTIL_FREEBSD @@ -343,10 +344,7 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) { py_name // (pystr) name ); - if (py_retlist != NULL) { - // XXX shall we decref() also in case of Py_BuildValue() error? - Py_DECREF(py_name); - } + Py_DECREF(py_name); return py_retlist; } |