Added checks to encoding conversion to avoid crash
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51458 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -974,6 +974,9 @@ wxTextCtrl::StreamIn(const wxString& value,
|
||||
|
||||
const size_t len = conv.MB2WC(NULL, value.mb_str(), value.length());
|
||||
|
||||
if (len == wxCONV_FAILED)
|
||||
return false;
|
||||
|
||||
#if wxUSE_WCHAR_T
|
||||
wxWCharBuffer wchBuf(len);
|
||||
wchar_t *wpc = wchBuf.data();
|
||||
@@ -1066,7 +1069,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