Fix wrong null character stripping for FormatMessage (Nikita Kniazev)

This commit is contained in:
Peter Dimov
2019-03-24 01:59:23 +02:00
parent 90b2356015
commit 9b8cb7f1f6

View File

@ -126,6 +126,7 @@ inline char const * system_category_message_win32( int ev, char * buffer, std::s
{
r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, buffer, static_cast<int>( len ), NULL, NULL );
boost::winapi::LocalFree( lpMsgBuf );
if ( r != 0 ) --r; // exclude null terminator
}
}
@ -134,8 +135,6 @@ inline char const * system_category_message_win32( int ev, char * buffer, std::s
return unknown_message_win32( ev, buffer, len );
}
--r; // exclude null terminator
while( r > 0 && ( buffer[ r-1 ] == '\n' || buffer[ r-1 ] == '\r' ) )
{
buffer[ --r ] = 0;