Check for NULL familyName in SkFontMgr_fontconfig.
authorbungeman <bungeman@google.com>
Wed, 29 Apr 2015 21:35:49 +0000 (14:35 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 29 Apr 2015 21:35:50 +0000 (14:35 -0700)
If the familyName is NULL, don't bother spending time trying to add
it to the FcPattern.

Review URL: https://codereview.chromium.org/1115073002

src/ports/SkFontMgr_fontconfig.cpp

index 58597d9..f03e5ac 100644 (file)
@@ -771,10 +771,12 @@ protected:
         FCLocker lock;
 
         SkAutoFcPattern pattern;
-        FcValue familyNameValue;
-        familyNameValue.type = FcTypeString;
-        familyNameValue.u.s = reinterpret_cast<const FcChar8*>(familyName);
-        FcPatternAddWeak(pattern, FC_FAMILY, familyNameValue, FcFalse);
+        if (familyName) {
+            FcValue familyNameValue;
+            familyNameValue.type = FcTypeString;
+            familyNameValue.u.s = reinterpret_cast<const FcChar8*>(familyName);
+            FcPatternAddWeak(pattern, FC_FAMILY, familyNameValue, FcFalse);
+        }
         fcpattern_from_skfontstyle(style, pattern);
 
         SkAutoFcCharSet charSet;