Fix crashes when pasting non-text data in wxOSX
Check that conversions succeed before using their results to avoid crashing if the data on clipboard is in an unexpected format. Closes #18344.
This commit is contained in:
@@ -469,14 +469,20 @@ bool wxDataObject::GetFromPasteboard( void * pb )
|
||||
{
|
||||
// revert the translation and decomposition to arrive at a proper utf8 string again
|
||||
CFURLRef url = CFURLCreateWithBytes( kCFAllocatorDefault, CFDataGetBytePtr( flavorData ), flavorDataSize, kCFStringEncodingUTF8, NULL );
|
||||
CFStringRef cfString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle );
|
||||
CFRelease( url );
|
||||
CFMutableStringRef cfMutableString = CFStringCreateMutableCopy(NULL, 0, cfString);
|
||||
CFRelease( cfString );
|
||||
CFStringNormalize(cfMutableString,kCFStringNormalizationFormC);
|
||||
wxString path = wxCFStringRef(cfMutableString).AsString();
|
||||
if (!path.empty())
|
||||
filenamesPassed += path + wxT("\n");
|
||||
if ( url )
|
||||
{
|
||||
CFStringRef cfString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle );
|
||||
CFRelease( url );
|
||||
if ( cfString )
|
||||
{
|
||||
CFMutableStringRef cfMutableString = CFStringCreateMutableCopy(NULL, 0, cfString);
|
||||
CFRelease( cfString );
|
||||
CFStringNormalize(cfMutableString,kCFStringNormalizationFormC);
|
||||
wxString path = wxCFStringRef(cfMutableString).AsString();
|
||||
if (!path.empty())
|
||||
filenamesPassed += path + wxT("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user