 Chromium Code Reviews
 Chromium Code Reviews Issue 365683004:
  CTFontCopy*Name may return NULL.  (Closed) 
  Base URL: https://skia.googlesource.com/skia.git@master
    
  
    Issue 365683004:
  CTFontCopy*Name may return NULL.  (Closed) 
  Base URL: https://skia.googlesource.com/skia.git@master| Index: src/ports/SkFontHost_mac.cpp | 
| diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp | 
| index 77bf4b873b7fd3e21ab2e7ed29fd321c891326f6..06e6fac2f75347c8ff076891d4bcbe79bf1a5dd2 100755 | 
| --- a/src/ports/SkFontHost_mac.cpp | 
| +++ b/src/ports/SkFontHost_mac.cpp | 
| @@ -1520,7 +1520,7 @@ static bool getWidthAdvance(CTFontRef ctFont, int gId, int16_t* data) { | 
| return true; | 
| } | 
| -// we might move this into our CGUtils... | 
| +/** Assumes src and dst are not NULL. */ | 
| static void CFStringToSkString(CFStringRef src, SkString* dst) { | 
| // Reserve enough room for the worst-case string, | 
| // plus 1 byte for the trailing null. | 
| @@ -1544,7 +1544,9 @@ SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics( | 
| { | 
| AutoCFRelease<CFStringRef> fontName(CTFontCopyPostScriptName(ctFont)); | 
| - CFStringToSkString(fontName, &info->fFontName); | 
| + if (fontName.get()) { | 
| + CFStringToSkString(fontName, &info->fFontName); | 
| + } | 
| } | 
| CFIndex glyphCount = CTFontGetGlyphCount(ctFont); | 
| @@ -1899,6 +1901,9 @@ void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const { | 
| // we take ownership of the ref | 
| static const char* get_str(CFStringRef ref, SkString* str) { | 
| 
reed1
2014/07/01 18:46:23
does our caller (in this file) know to look for NU
 | 
| + if (NULL == ref) { | 
| + return NULL; | 
| + } | 
| CFStringToSkString(ref, str); | 
| CFSafeRelease(ref); | 
| return str->c_str(); |