diff --git a/include/boost/system/detail/system_category_win32.hpp b/include/boost/system/detail/system_category_win32.hpp index ba10708..a46c8b2 100644 --- a/include/boost/system/detail/system_category_win32.hpp +++ b/include/boost/system/detail/system_category_win32.hpp @@ -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( 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;