diff --git a/src/osx/core/cfstring.cpp b/src/osx/core/cfstring.cpp index 612dc39a5d..27471b24e5 100644 --- a/src/osx/core/cfstring.cpp +++ b/src/osx/core/cfstring.cpp @@ -621,9 +621,16 @@ wxCFStringRef::wxCFStringRef( const wxString &st , wxFontEncoding WXUNUSED_IN_UN #else #error "unsupported Unicode representation" #endif - - reset( CFStringCreateWithBytes( kCFAllocatorDefault, - (const UInt8*)data, size, cfencoding, false /* no BOM */ ) ); + CFStringref ref = CFStringCreateWithBytes( kCFAllocatorDefault, + (const UInt8*)data, size, cfencoding, false /* no BOM */ ); + if (ref) + { + reset( ref ); + } + else + { + reset( wxCFRetain( CFSTR("") ) ); + } #else // not wxUSE_UNICODE reset( CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , wxMacGetSystemEncFromFontEnc( encoding ) ) );