From 251244a0200160fdea56437a0cafacee0010a8bc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 31 Dec 2001 02:41:25 +0000 Subject: [PATCH] fixed a harmless buglet in wxSysErrorMsg() under Win32 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13263 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/log.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/common/log.cpp b/src/common/log.cpp index be03d3c4c8..afcc832ec2 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -732,20 +732,23 @@ const wxChar *wxSysErrorMsg(unsigned long nErrCode) 0, NULL); // copy it to our buffer and free memory - if( lpMsgBuf != 0 ) + if( lpMsgBuf != 0 ) { wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1); - else - s_szBuf[0] = wxT('\0'); - s_szBuf[WXSIZEOF(s_szBuf) - 1] = wxT('\0'); - LocalFree(lpMsgBuf); + s_szBuf[WXSIZEOF(s_szBuf) - 1] = wxT('\0'); - // returned string is capitalized and ended with '\r\n' - bad - s_szBuf[0] = (wxChar)wxTolower(s_szBuf[0]); - size_t len = wxStrlen(s_szBuf); - if ( len > 0 ) { - // truncate string - if ( s_szBuf[len - 2] == wxT('\r') ) - s_szBuf[len - 2] = wxT('\0'); + LocalFree(lpMsgBuf); + + // returned string is capitalized and ended with '\r\n' - bad + s_szBuf[0] = (wxChar)wxTolower(s_szBuf[0]); + size_t len = wxStrlen(s_szBuf); + if ( len > 0 ) { + // truncate string + if ( s_szBuf[len - 2] == wxT('\r') ) + s_szBuf[len - 2] = wxT('\0'); + } + } + else { + s_szBuf[0] = wxT('\0'); } return s_szBuf;