Skip to content

Commit

Permalink
fix: fix closing mutex handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Bush2021 committed Dec 6, 2024
1 parent 106a60e commit 9d3e62e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,13 @@ std::wstring GetCommand(LPWSTR param) {
return JoinArgsString(args, L" ");
}

HANDLE hMutex = nullptr;
bool IsFirstRun() {
if (GetLaunchOnStartup().empty() && GetLaunchOnExit().empty()) {
return false;
}
HANDLE hMutex =
CreateMutexW(nullptr, TRUE, L"Global\\ChromePlusFirstRunMutex");
hMutex = CreateMutexW(nullptr, TRUE, L"Global\\ChromePlusFirstRunMutex");
if (hMutex == nullptr || GetLastError() == ERROR_ALREADY_EXISTS) {
if (hMutex) {
CloseHandle(hMutex);
}
return false;
}
return true;
Expand Down Expand Up @@ -135,7 +132,7 @@ void Portable(LPWSTR param) {
if (ShellExecuteEx(&sei)) {
if (first_run) {
WaitForSingleObject(sei.hProcess, INFINITE);
CloseHandle(sei.hProcess);
CloseHandle(hMutex);
KillLaunchOnExit(&program_handles);
LaunchCommands(GetLaunchOnExit(), SW_HIDE, nullptr);
}
Expand Down

0 comments on commit 9d3e62e

Please sign in to comment.