Fix bug in wxMBConv_cf::FromWChar() in OS X.
Apparently CFStringGetBytes() doesn't always behave as expected, work around this by checking that the returned buffer size is not greater than the size we passed in. Closes #11859. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63772 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
d16ba4644a
commit
eb08702932
@ -212,13 +212,15 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf(wxFontEncoding encoding)
|
||||
m_encoding,
|
||||
0, // FAIL on unconvertible characters
|
||||
false, // not an external representation
|
||||
// if dstSize is 0 then pass NULL to get required length in usedBufLen
|
||||
(dstSize != 0)?(UInt8*)dst:NULL,
|
||||
(UInt8*)dst,
|
||||
dstSize,
|
||||
&usedBufLen
|
||||
);
|
||||
|
||||
if(charsConverted < CFStringGetLength(theString) )
|
||||
// when dst is non-NULL, we check usedBufLen against dstSize as
|
||||
// CFStringGetBytes sometimes treats dst as being NULL when dstSize==0
|
||||
if( (charsConverted < CFStringGetLength(theString)) ||
|
||||
(dst && (size_t) usedBufLen > dstSize) )
|
||||
return wxCONV_FAILED;
|
||||
|
||||
return usedBufLen;
|
||||
|
Loading…
Reference in New Issue
Block a user