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
|
// revert the translation and decomposition to arrive at a proper utf8 string again
|
||||||
CFURLRef url = CFURLCreateWithBytes( kCFAllocatorDefault, CFDataGetBytePtr( flavorData ), flavorDataSize, kCFStringEncodingUTF8, NULL );
|
CFURLRef url = CFURLCreateWithBytes( kCFAllocatorDefault, CFDataGetBytePtr( flavorData ), flavorDataSize, kCFStringEncodingUTF8, NULL );
|
||||||
CFStringRef cfString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle );
|
if ( url )
|
||||||
CFRelease( url );
|
{
|
||||||
CFMutableStringRef cfMutableString = CFStringCreateMutableCopy(NULL, 0, cfString);
|
CFStringRef cfString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle );
|
||||||
CFRelease( cfString );
|
CFRelease( url );
|
||||||
CFStringNormalize(cfMutableString,kCFStringNormalizationFormC);
|
if ( cfString )
|
||||||
wxString path = wxCFStringRef(cfMutableString).AsString();
|
{
|
||||||
if (!path.empty())
|
CFMutableStringRef cfMutableString = CFStringCreateMutableCopy(NULL, 0, cfString);
|
||||||
filenamesPassed += path + wxT("\n");
|
CFRelease( cfString );
|
||||||
|
CFStringNormalize(cfMutableString,kCFStringNormalizationFormC);
|
||||||
|
wxString path = wxCFStringRef(cfMutableString).AsString();
|
||||||
|
if (!path.empty())
|
||||||
|
filenamesPassed += path + wxT("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user