don't crash if FormatMessage() fails in wxSysErrorMsg()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34554 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -737,14 +737,26 @@ const wxChar *wxSysErrorMsg(unsigned long nErrCode)
|
|||||||
|
|
||||||
// get error message from system
|
// get error message from system
|
||||||
LPVOID lpMsgBuf;
|
LPVOID lpMsgBuf;
|
||||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
if ( ::FormatMessage
|
||||||
NULL, nErrCode,
|
(
|
||||||
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL,
|
||||||
|
nErrCode,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
(LPTSTR)&lpMsgBuf,
|
(LPTSTR)&lpMsgBuf,
|
||||||
0, NULL);
|
0,
|
||||||
|
NULL
|
||||||
|
) == 0 )
|
||||||
|
{
|
||||||
|
// if this happens, something is seriously wrong, so don't use _() here
|
||||||
|
// for safety
|
||||||
|
wxSprintf(s_szBuf, _T("unknown error %lx"), nErrCode);
|
||||||
|
return s_szBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// copy it to our buffer and free memory
|
// copy it to our buffer and free memory
|
||||||
// Crashes on SmartPhone
|
// Crashes on SmartPhone (FIXME)
|
||||||
#if !defined(__SMARTPHONE__) /* of WinCE */
|
#if !defined(__SMARTPHONE__) /* of WinCE */
|
||||||
if( lpMsgBuf != 0 ) {
|
if( lpMsgBuf != 0 ) {
|
||||||
wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1);
|
wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1);
|
||||||
|
Reference in New Issue
Block a user