Fixed potential buffer overrun in Win32 OpenGL error handling
This fixes issue #1245.
This commit is contained in:
parent
bf92efe9a4
commit
0980e90ee4
@ -66,13 +66,17 @@ void ensureExtensionsInit(HDC deviceContext)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
String getErrorString(DWORD errorCode)
|
String getErrorString(DWORD errorCode)
|
||||||
{
|
{
|
||||||
std::basic_ostringstream<TCHAR, std::char_traits<TCHAR> > ss;
|
PTCHAR buffer;
|
||||||
TCHAR errBuff[256];
|
if (FormatMessage(FORMAT_MESSAGE_MAX_WIDTH_MASK | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorCode, 0, reinterpret_cast<LPTSTR>(&buffer), 256, NULL) != 0)
|
||||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errorCode, 0, errBuff, sizeof(errBuff), NULL);
|
{
|
||||||
ss << errBuff;
|
String errMsg(buffer);
|
||||||
String errMsg(ss.str());
|
LocalFree(buffer);
|
||||||
|
|
||||||
return errMsg;
|
return errMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostringstream ss;
|
||||||
|
ss << "Error " << errorCode;
|
||||||
|
return String(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user