MI Refactor CMIUtilSystemWindows::GetExecutablesPath()
Summary: My understanding of the Windows API call GetLastError() is that it should only be checked when ::GetModuleFileName() returns 0 on error. Otherwise GetExecutablesPath() could return an error despite nLen being valid if GetLastError() was inconsistent. Patch updates function to only call GetOSLastError() when nLen == 0 Patch from ewan@codeplay.com Reviewers: EwanCrawford Subscribers: lldb-commits, deepak2427 Differential Revision: http://reviews.llvm.org/D9154 llvm-svn: 235515
This commit is contained in:
parent
badf3a6356
commit
5a931869d4
|
@ -110,15 +110,13 @@ CMIUtilSystemWindows::GetExecutablesPath(CMIUtilString &vrwFileNamePath) const
|
|||
bool bOk = MIstatus::success;
|
||||
HMODULE hModule = ::GetModuleHandle(nullptr);
|
||||
char pPath[MAX_PATH];
|
||||
const DWORD nLen = ::GetModuleFileName(hModule, &pPath[0], MAX_PATH);
|
||||
const CMIUtilString strLastErr(GetOSLastError());
|
||||
if ((nLen != 0) && (strLastErr == "Unknown OS error"))
|
||||
vrwFileNamePath = &pPath[0];
|
||||
else
|
||||
if (!::GetModuleFileName(hModule, &pPath[0], MAX_PATH))
|
||||
{
|
||||
bOk = MIstatus::failure;
|
||||
vrwFileNamePath = strLastErr;
|
||||
vrwFileNamePath = GetOSLastError();
|
||||
}
|
||||
else
|
||||
vrwFileNamePath = &pPath[0];
|
||||
|
||||
return bOk;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue