mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-23 19:17:17 +00:00
Checking for a return value with FormatMessage; if the call fails, there's no guarantee that the buffer will be non-null.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195019 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
eae6e546ec
commit
7c5498ee55
@ -39,11 +39,16 @@ inline bool MakeErrMsg(std::string* ErrMsg, const std::string& prefix) {
|
||||
if (!ErrMsg)
|
||||
return true;
|
||||
char *buffer = NULL;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
|
||||
*ErrMsg = prefix + buffer;
|
||||
DWORD R = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
|
||||
if (R)
|
||||
*ErrMsg = prefix + buffer;
|
||||
else
|
||||
*ErrMsg = prefix + "Unknown error";
|
||||
|
||||
LocalFree(buffer);
|
||||
return true;
|
||||
return R != 0;
|
||||
}
|
||||
|
||||
template <typename HandleTraits>
|
||||
|
Loading…
x
Reference in New Issue
Block a user