make string at least empty (instead of containing garbage) if malloc() failed
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21858 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -260,9 +260,9 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength)
|
||||
if ( !AllocBuffer(nLen) )
|
||||
{
|
||||
wxFAIL_MSG( _T("out of memory in wxString::wxString") );
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// MB2WC wants the buffer size, not the string length
|
||||
if ( conv.MB2WC(m_pchData, psz, nLen + 1) != (size_t)-1 )
|
||||
{
|
||||
@@ -272,6 +272,7 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength)
|
||||
}
|
||||
//else: the conversion failed -- leave the string empty (what else?)
|
||||
}
|
||||
}
|
||||
|
||||
Init();
|
||||
}
|
||||
@@ -301,9 +302,9 @@ wxString::wxString(const wchar_t *pwz, wxMBConv& conv, size_t nLength)
|
||||
if ( !AllocBuffer(nLen) )
|
||||
{
|
||||
wxFAIL_MSG( _T("out of memory in wxString::wxString") );
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// WC2MB wants the buffer size, not the string length
|
||||
if ( conv.WC2MB(m_pchData, pwz, nLen + 1) != (size_t)-1 )
|
||||
{
|
||||
@@ -312,6 +313,7 @@ wxString::wxString(const wchar_t *pwz, wxMBConv& conv, size_t nLength)
|
||||
}
|
||||
//else: the conversion failed -- leave the string empty (what else?)
|
||||
}
|
||||
}
|
||||
|
||||
Init();
|
||||
}
|
||||
|
Reference in New Issue
Block a user