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:
@@ -212,13 +212,15 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf(wxFontEncoding encoding)
|
|||||||
m_encoding,
|
m_encoding,
|
||||||
0, // FAIL on unconvertible characters
|
0, // FAIL on unconvertible characters
|
||||||
false, // not an external representation
|
false, // not an external representation
|
||||||
// if dstSize is 0 then pass NULL to get required length in usedBufLen
|
(UInt8*)dst,
|
||||||
(dstSize != 0)?(UInt8*)dst:NULL,
|
|
||||||
dstSize,
|
dstSize,
|
||||||
&usedBufLen
|
&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 wxCONV_FAILED;
|
||||||
|
|
||||||
return usedBufLen;
|
return usedBufLen;
|
||||||
|
|||||||
Reference in New Issue
Block a user