make the string properly 0 terminated and allow for one char more on the output buffer
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38639 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
2dcd83af91
commit
3281bf6779
@ -504,19 +504,20 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
|
||||
UniChar buf[2] ;
|
||||
if ( GetEventParameter( event, kEventParamTextInputSendText, typeUnicodeText, NULL, 0 , &dataSize, NULL ) == noErr )
|
||||
{
|
||||
numChars = dataSize / sizeof( UniChar) ;
|
||||
numChars = dataSize / sizeof( UniChar) + 1;
|
||||
charBuf = buf ;
|
||||
|
||||
if ( dataSize > sizeof(buf) )
|
||||
if ( numChars * 2 > sizeof(buf) )
|
||||
charBuf = new UniChar[ numChars ] ;
|
||||
else
|
||||
charBuf = buf ;
|
||||
|
||||
uniChars = new wchar_t[ numChars ] ;
|
||||
GetEventParameter( event, kEventParamTextInputSendText, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
|
||||
charBuf[ numChars - 1 ] = 0;
|
||||
#if SIZEOF_WCHAR_T == 2
|
||||
uniChars = (wchar_t*) charBuf ;
|
||||
memcpy( uniChars , charBuf , dataSize ) ;
|
||||
memcpy( uniChars , charBuf , numChars * 2 ) ;
|
||||
#else
|
||||
// the resulting string will never have more chars than the utf16 version, so this is safe
|
||||
wxMBConvUTF16 converter ;
|
||||
|
Loading…
Reference in New Issue
Block a user