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