From c42b133098b09da556d02420e72ed19ce633fd85 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Fri, 10 Dec 2010 19:37:19 +0100 Subject: [PATCH] Check for conversion error in Core Text renderer Original patch by Kazuki Sakamoto. --- src/MacVim/MMCoreTextView.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index 3aed3568fe..b161015385 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -927,6 +927,10 @@ defaultAdvanceForFont(CTFontRef fontRef) // Convert UTF-8 chars to UTF-16 CFStringRef sref = CFStringCreateWithBytesNoCopy(NULL, s, len, kCFStringEncodingUTF8, false, kCFAllocatorNull); + if (sref == NULL) { + ASLogWarn(@"Conversion error: some text may not be rendered"); + continue; + } CFIndex unilength = CFStringGetLength(sref); const UniChar *unichars = CFStringGetCharactersPtr(sref); UniChar *buffer = NULL;