#3022: Process::isRunning(PID pid) causes handle leak on Windows

This commit is contained in:
Günter Obiltschnig
2021-06-14 17:25:08 +02:00
parent ab010473b9
commit 842f2599c0

View File

@@ -411,9 +411,17 @@ bool ProcessImpl::isRunningImpl(PIDImpl pid)
{
HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
bool result = true;
DWORD exitCode;
BOOL rc = GetExitCodeProcess(hProc, &exitCode);
if (!rc || exitCode != STILL_ACTIVE) result = false;
if (hProc)
{
DWORD exitCode;
BOOL rc = GetExitCodeProcess(hProc, &exitCode);
if (!rc || exitCode != STILL_ACTIVE) result = false;
CloseHandle(hProc);
}
else
{
result = false;
}
return result;
}