diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-08-13 10:23:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-13 10:23:28 +0200 |
commit | ec1e8843cf91bb898f54cc56ba2c6b4a8df3c612 (patch) | |
tree | 984a533c3b04a072fa7adf5115356dcd38eb89a5 | |
parent | fed34c3fef480b84f4e1ec34d19b72534f99dfac (diff) | |
parent | b1e0da455b2ac9a63e092eacda6927032add8b30 (diff) |
Merge pull request #20595 from dragmz/fix-windows-process-handles-leak
Fix Windows handles leak
-rw-r--r-- | platform/windows/os_windows.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index bd76db8796..033654323b 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2309,6 +2309,8 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, if (r_exitcode) *r_exitcode = ret; + CloseHandle(pi.pi.hProcess); + CloseHandle(pi.pi.hThread); } else { ProcessID pid = pi.pi.dwProcessId; @@ -2322,17 +2324,15 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, Error OS_Windows::kill(const ProcessID &p_pid) { - HANDLE h; + ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED); - if (process_map->has(p_pid)) { - h = (*process_map)[p_pid].pi.hProcess; - process_map->erase(p_pid); - } else { + const PROCESS_INFORMATION pi = (*process_map)[p_pid].pi; + process_map->erase(p_pid); - ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED); - }; + const int ret = TerminateProcess(pi.hProcess, 0); - int ret = TerminateProcess(h, 0); + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); return ret != 0 ? OK : FAILED; }; |