Added checks to encoding conversion to avoid crash
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@51457 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -940,6 +940,9 @@ wxTextCtrl::StreamIn(const wxString& value,
|
||||
|
||||
const size_t len = conv.MB2WC(NULL, value, value.length());
|
||||
|
||||
if (len == wxCONV_FAILED)
|
||||
return false;
|
||||
|
||||
#if wxUSE_WCHAR_T
|
||||
wxWCharBuffer wchBuf(len);
|
||||
wchar_t *wpc = wchBuf.data();
|
||||
@@ -1032,7 +1035,8 @@ wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const
|
||||
// conversion but what else can we do)
|
||||
wxCSConv conv(encoding);
|
||||
size_t lenNeeded = conv.WC2MB(NULL, wchBuf, 0);
|
||||
if ( lenNeeded++ )
|
||||
|
||||
if ( lenNeeded != wxCONV_FAILED && lenNeeded++ )
|
||||
{
|
||||
conv.WC2MB(wxStringBuffer(out, lenNeeded), wchBuf, lenNeeded);
|
||||
}
|
||||
|
Reference in New Issue
Block a user