Consider native data format, zero out buffer before use in case it doesn't get filled [ patch 1237326 ]
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34874 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
e0a3672027
commit
99b62b5ffc
@ -96,7 +96,12 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
|
||||
if ( dataFormat.GetType() == wxDF_TEXT )
|
||||
((char*)data)[byteCount] = 0 ;
|
||||
if ( dataFormat.GetType() == wxDF_UNICODETEXT )
|
||||
((wxChar*)data)[byteCount/2] = 0 ;
|
||||
{
|
||||
// "data" format is UTF16, so 2 bytes = one character
|
||||
// wxChar size depends on platform, so just clear last 2 bytes
|
||||
((char*)data)[byteCount] = 0;
|
||||
((char*)data)[byteCount+1] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -244,6 +249,8 @@ bool wxClipboard::AddData( wxDataObject *data )
|
||||
void* buf = malloc( sz + 1 ) ;
|
||||
if ( buf )
|
||||
{
|
||||
// empty the buffer because in some case GetDataHere does not fill buf
|
||||
memset(buf, 0, sz+1);
|
||||
data->GetDataHere( array[i] , buf ) ;
|
||||
OSType mactype = 0 ;
|
||||
switch ( array[i].GetType() )
|
||||
@ -380,6 +387,7 @@ bool wxClipboard::GetData( wxDataObject& data )
|
||||
switch ( format.GetType() )
|
||||
{
|
||||
case wxDF_TEXT :
|
||||
case wxDF_UNICODETEXT:
|
||||
case wxDF_OEMTEXT :
|
||||
case wxDF_BITMAP :
|
||||
case wxDF_METAFILE :
|
||||
|
Loading…
Reference in New Issue
Block a user