Added null checks to wxTextObjectData::GetDataHere and GetDataSize [ patch 1237326 ]

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34873 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Hock 2005-07-17 03:15:50 +00:00
parent 28ea89b62b
commit e0a3672027

View File

@ -287,7 +287,8 @@ size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const
else // == wxDF_TEXT
{
wxCharBuffer buffer = wxConvLibc.cWX2MB( GetText().c_str() );
return strlen( (const char*) buffer ) + 1;
// in some cases "buffer" is null (e.g. Mac OS X)
return buffer ? strlen( (const char*) buffer ) + 1 : 0;
}
}
@ -304,7 +305,9 @@ bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const
else
{
wxCharBuffer buffer = wxConvLibc.cWX2MB( GetText().c_str() );
strcpy( (char*) buf, (const char*) buffer );
// in some cases "buffer" is null (e.g. Mac OS X)
if (buffer)
strcpy( (char*) buf, (const char*) buffer );
}
return true;