Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Unified Diff: src/ports/SkFontHost_mac.cpp

Issue 365683004: CTFontCopy*Name may return NULL. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698