Skip to content

Commit

Permalink
Fix: Accessing member of deleted objects
Browse files Browse the repository at this point in the history
  • Loading branch information
scuzqy committed Feb 24, 2024
1 parent 507434e commit 4092d98
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/windows/windriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class Driver
if (err == ERROR_SERVICE_ALREADY_RUNNING) return true;

std::wcerr << "Starting MSR service failed with error " << err << " ";
const TCHAR * errorStr = _com_error(err).ErrorMessage();
const _com_error comError{ (int)err };
const TCHAR * errorStr = comError.ErrorMessage();
if (errorStr)
std::wcerr << errorStr << "\n";

Expand All @@ -120,7 +121,8 @@ class Driver
else
{
std::wcerr << "Opening service manager failed with error " << GetLastError() << " ";
const TCHAR * errorStr = _com_error(GetLastError()).ErrorMessage();
const _com_error comError{ (int)GetLastError() };
const TCHAR * errorStr = comError.ErrorMessage();
if (errorStr)
std::wcerr << errorStr << "\n";
}
Expand All @@ -130,7 +132,8 @@ class Driver
else
{
std::wcerr << "Opening service manager failed with error " << GetLastError() << " ";
const TCHAR * errorStr = _com_error(GetLastError()).ErrorMessage();
const _com_error comError{ (int)GetLastError() };
const TCHAR * errorStr = comError.ErrorMessage();
if (errorStr)
std::wcerr << errorStr << "\n";
}
Expand Down Expand Up @@ -169,7 +172,8 @@ class Driver
else
{
std::wcerr << "Opening service manager failed with error " << GetLastError() << " ";
const TCHAR * errorStr = _com_error(GetLastError()).ErrorMessage();
const _com_error comError{ (int)GetLastError() };
const TCHAR * errorStr = comError.ErrorMessage();
if (errorStr)
std::wcerr << errorStr;
}
Expand Down Expand Up @@ -197,7 +201,8 @@ class Driver
else
{
std::wcerr << "Opening service manager failed with error " << GetLastError() << " ";
const TCHAR * errorStr = _com_error(GetLastError()).ErrorMessage();
const _com_error comError{ (int)GetLastError() };
const TCHAR * errorStr = comError.ErrorMessage();
if (errorStr)
std::wcerr << errorStr;
}
Expand Down

0 comments on commit 4092d98

Please sign in to comment.