diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2019-02-04 16:07:51 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2019-02-04 16:07:51 +0100 |
commit | 3f9643f2357e887bff3ab4ecf093b9f28fa53fe9 (patch) | |
tree | 1abed820a2f33cad68d9d4612c09b650fdb62cdb | |
parent | 584914306e50aec251476014ac3934810039e7b5 (diff) | |
download | psutil-3f9643f2357e887bff3ab4ecf093b9f28fa53fe9.tar.gz |
win / cmdline: add free() and CloseHandle() calls
-rw-r--r-- | psutil/arch/windows/process_info.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/psutil/arch/windows/process_info.c b/psutil/arch/windows/process_info.c index f897bde5..051b1c6d 100644 --- a/psutil/arch/windows/process_info.c +++ b/psutil/arch/windows/process_info.c @@ -856,6 +856,11 @@ error: } +/* + * Get process cmdline() by using NtQueryInformationProcess. This is + * useful on Windows 8.1+ in order to get less ERROR_ACCESS_DENIED + * errors when querying privileged PIDs. + */ static int psutil_get_cmdline_data(long pid, WCHAR **pdata, SIZE_T *psize) { HANDLE hProcess; @@ -908,6 +913,8 @@ psutil_get_cmdline_data(long pid, WCHAR **pdata, SIZE_T *psize) { wcscpy_s(cmdline_buffer_wchar, string_size, tmp->Buffer); *pdata = cmdline_buffer_wchar; *psize = string_size * sizeof(WCHAR); + free(cmdline_buffer); + CloseHandle(hProcess); return 0; error: @@ -920,9 +927,9 @@ error: /* -* returns a Python list representing the arguments for the process -* with given pid or NULL on error. -*/ + * Return a Python list representing the arguments for the process + * with given pid or NULL on error. + */ PyObject * psutil_get_cmdline(long pid) { PyObject *ret = NULL; |