summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-10-17 02:17:01 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2020-10-17 02:17:01 +0200
commitb4c2124ff1f8f4f1f7f50ad0af6945b0d7e945df (patch)
treed42fbc60c00b478bec25cc6d6726e8054b6639bc
parent019546e395e0c15ff5c41f09ce2f53b99d8de8b3 (diff)
downloadpsutil-b4c2124ff1f8f4f1f7f50ad0af6945b0d7e945df.tar.gz
windows / open_files; check globalFileName is not NULL before accessing it; fix #1823 and #1763
-rw-r--r--HISTORY.rst2
-rw-r--r--psutil/arch/windows/process_handles.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index 1d760dbc..8c1c8a49 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -15,6 +15,8 @@ XXXX-XX-XX
**Bug fixes**
+- 1823_: [Windows] Process.open_files() may cause a segfault due to a NULL
+ pointer.
- 1838_: [Linux] sensors_battery(): if `percent` can be determined but not
the remaining values, still return a result instead of None.
(patch by aristocratos)
diff --git a/psutil/arch/windows/process_handles.c b/psutil/arch/windows/process_handles.c
index f63d4af3..72e3f4d4 100644
--- a/psutil/arch/windows/process_handles.c
+++ b/psutil/arch/windows/process_handles.c
@@ -247,7 +247,7 @@ psutil_get_open_files(DWORD dwPid, HANDLE hProcess) {
if (psutil_threaded_get_filename(hFile) != 0)
goto error;
- if (globalFileName->Length > 0) {
+ if ((globalFileName != NULL) && (globalFileName->Length > 0)) {
py_path = PyUnicode_FromWideChar(globalFileName->Buffer,
wcslen(globalFileName->Buffer));
if (! py_path)