Skip to content

Commit

Permalink
Fixed potential buffer overrun in Win32 OpenGL error handling
Browse files Browse the repository at this point in the history
This fixes issue #1245.
  • Loading branch information
MarioLiebisch authored and eXpl0it3r committed Jan 19, 2019
1 parent b516a3a commit e12d28d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/SFML/Window/Win32/WglContext.cpp
Expand Up @@ -66,13 +66,17 @@ void ensureExtensionsInit(HDC deviceContext)
////////////////////////////////////////////////////////////
String getErrorString(DWORD errorCode)
{
std::basic_ostringstream<TCHAR, std::char_traits<TCHAR> > ss;
TCHAR errBuff[256];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errorCode, 0, errBuff, sizeof(errBuff), NULL);
ss << errBuff;
String errMsg(ss.str());
PTCHAR buffer;
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)
{
String errMsg(buffer);
LocalFree(buffer);
return errMsg;
}

return errMsg;
std::ostringstream ss;
ss << "Error " << errorCode;
return String(ss.str());
}


Expand Down

0 comments on commit e12d28d

Please sign in to comment.